Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

DefaultItemAnimator

open class DefaultItemAnimator : SimpleItemAnimator
kotlin.Any
   ↳ androidx.recyclerview.widget.RecyclerView.ItemAnimator
   ↳ androidx.recyclerview.widget.SimpleItemAnimator
   ↳ androidx.recyclerview.widget.DefaultItemAnimator

This implementation of RecyclerView.ItemAnimator provides basic animations on remove, add, and move events that happen to the items in a RecyclerView. RecyclerView uses a DefaultItemAnimator by default.

Summary

Inherited constants
Public constructors

This implementation of RecyclerView.ItemAnimator provides basic animations on remove, add, and move events that happen to the items in a RecyclerView.

Public methods
open Boolean
canReuseUpdatedViewHolder(@NonNull viewHolder: RecyclerView.ViewHolder, @NonNull payloads: MutableList<Any!>)

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).

open Boolean

open Unit

open Boolean
animateMove(holder: RecyclerView.ViewHolder!, fromX: Int, fromY: Int, toX: Int, toY: Int)

open Boolean
animateChange(oldHolder: RecyclerView.ViewHolder!, newHolder: RecyclerView.ViewHolder!, fromX: Int, fromY: Int, toX: Int, toY: Int)

open Boolean

open Unit

open Boolean

open Unit

Inherited functions

Public constructors

<init>

DefaultItemAnimator()

This implementation of RecyclerView.ItemAnimator provides basic animations on remove, add, and move events that happen to the items in a RecyclerView. RecyclerView uses a DefaultItemAnimator by default.

Public methods

canReuseUpdatedViewHolder

open fun canReuseUpdatedViewHolder(@NonNull viewHolder: RecyclerView.ViewHolder, @NonNull payloads: MutableList<Any!>): Boolean

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 (Adapter#getItemViewType(int)). Otherwise, ItemAnimator will always receive both ViewHolders in the animateChange(ViewHolder, ViewHolder, ItemHolderInfo, ItemHolderInfo) method.

If the payload list is not empty, DefaultItemAnimator returns true. When this is the case:

Parameters
viewHolder RecyclerView.ViewHolder: The ViewHolder which represents the changed item's old content.
payloads RecyclerView.ViewHolder: A non-null list of merged payloads that were sent with change notifications. Can be empty if the adapter is invalidated via RecyclerView.Adapter#notifyDataSetChanged(). The same list of payloads will be passed into RecyclerView.Adapter#onBindViewHolder(ViewHolder, int, List) method if this method returns true.
Return
Boolean: 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(ViewHolder).

animateAdd

open fun animateAdd(holder: RecyclerView.ViewHolder!): Boolean

runPendingAnimations

open fun runPendingAnimations(): Unit

animateMove

open fun animateMove(holder: RecyclerView.ViewHolder!, fromX: Int, fromY: Int, toX: Int, toY: Int): Boolean

animateChange

open fun animateChange(oldHolder: RecyclerView.ViewHolder!, newHolder: RecyclerView.ViewHolder!, fromX: Int, fromY: Int, toX: Int, toY: Int): Boolean

isRunning

open fun isRunning(): Boolean

endAnimation

open fun endAnimation(item: RecyclerView.ViewHolder): Unit

animateRemove

open fun animateRemove(holder: RecyclerView.ViewHolder!): Boolean

endAnimations

open fun endAnimations(): Unit