You can use

mAdapter.notifyItemChanged(index,1)

The first parameter index is which item should be refreshed and the second parameter is which controls in which item should be refreshed and we need to deal with that, or we don’t pass the whole item to refresh;

Duplicate in Adapter

onBindViewHolder(
        holder: BaseViewHolder,
        position: Int,
        payloads: MutableList<Any>
    ) 
Copy the code

The method is as follows:

    override fun onBindViewHolder(
        holder: BaseViewHolder,
        position: Int,
        payloads: MutableList<Any>
    ) {
       if (payloads.isEmpty()){
           onBindViewHolder(holder,position)
       }else{
           super.onBindViewHolder(holder, position)
       }
    }
Copy the code

Payloads is when we’re refreshing and that item is the second parameter that’s passed in to determine which controls need to be refreshed based on the payloads; If this parameter is null, the entire item needs to be flushed

In some cases, the recycerView refresh will be flashing. We just need to disable the animation of recycleView as follows:

(swipeRecyclerView? .getItemAnimator() as DefaultItemAnimator).setSupportsChangeAnimations(false)
Copy the code

Another option is to set the animation playback time to 0; As follows:

swipeRecyclerView? .getItemAnimator()? .setChangeDuration(0); // Fix flicker by setting animation execution time to 0Copy the code

This method is not recommended, however, because in some cases the next item will wobble.