canReuseUpdatedViewHolder

When an item is changed, ItemAnimator can decide whether it wants to re-use the same ViewHolder for animations or RecyclerView should create a copy of the item and ItemAnimator will use both to run the animation (e.g. cross-fade).

Note that this method will only be called if the ViewHolder still has the same type (getItemViewType). Otherwise, ItemAnimator will always receive both ViewHolders in the animateChange method.

If your application is using change payloads, you can override canReuseUpdatedViewHolder to decide based on payloads.

Return

True if RecyclerView should just rebind to the same ViewHolder or false if RecyclerView should create a new ViewHolder and pass this ViewHolder to the ItemAnimator to animate. Default implementation returns true.

Parameters

viewHolder

The ViewHolder which represents the changed item's old content.

See also


When an item is changed, ItemAnimator can decide whether it wants to re-use the same ViewHolder for animations or RecyclerView should create a copy of the item and ItemAnimator will use both to run the animation (e.g. cross-fade).

Note that this method will only be called if the ViewHolder still has the same type (getItemViewType). Otherwise, ItemAnimator will always receive both ViewHolders in the animateChange method.

Return

True if RecyclerView should just rebind to the same ViewHolder or false if RecyclerView should create a new ViewHolder and pass this ViewHolder to the ItemAnimator to animate. Default implementation calls canReuseUpdatedViewHolder.

Parameters

viewHolder

The ViewHolder which represents the changed item's old content.

payloads

A non-null list of merged payloads that were sent with change notifications. Can be empty if the adapter is invalidated via notifyDataSetChanged. The same list of payloads will be passed into onBindViewHolder method if this method returns true.

See also