SimpleItemAnimator

public abstract class SimpleItemAnimator
extends RecyclerView.ItemAnimator

java.lang.Object
   ↳ androidx.recyclerview.widget.RecyclerView.ItemAnimator
     ↳ androidx.recyclerview.widget.SimpleItemAnimator


A wrapper class for ItemAnimator that records View bounds and decides whether it should run move, change, add or remove animations. This class also replicates the original ItemAnimator API.

It uses RecyclerView.ItemAnimator.ItemHolderInfo to track the bounds information of the Views. If you would like to extend this class, you can override RecyclerView.ItemAnimator.obtainHolderInfo() method to provide your own info class that extends RecyclerView.ItemAnimator.ItemHolderInfo.

Summary

Inherited constants

Public constructors

SimpleItemAnimator()

Public methods

abstract boolean animateAdd(RecyclerView.ViewHolder holder)

Called when an item is added to the RecyclerView.

boolean animateAppearance(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)

Called by the RecyclerView when a ViewHolder is added to the layout.

boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)

Called by the RecyclerView when an adapter item is present both before and after the layout and RecyclerView has received a RecyclerView.Adapter.notifyItemChanged(int) call for it.

abstract boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop)

Called when an item is changed in the RecyclerView, as indicated by a call to RecyclerView.Adapter.notifyItemChanged(int) or RecyclerView.Adapter.notifyItemRangeChanged(int, int).

boolean animateDisappearance(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)

Called by the RecyclerView when a ViewHolder has disappeared from the layout.

abstract boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY, int toX, int toY)

Called when an item is moved in the RecyclerView.

boolean animatePersistence(RecyclerView.ViewHolder viewHolder, RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)

Called by the RecyclerView when a ViewHolder is present in both before and after the layout and RecyclerView has not received a RecyclerView.Adapter.notifyItemChanged(int) call for it or a RecyclerView.Adapter.notifyDataSetChanged() call.

abstract boolean animateRemove(RecyclerView.ViewHolder holder)

Called when an item is removed from the RecyclerView.

boolean canReuseUpdatedViewHolder(RecyclerView.ViewHolder viewHolder)

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.

final void dispatchAddFinished(RecyclerView.ViewHolder item)

Method to be called by subclasses when an add animation is done.

final void dispatchAddStarting(RecyclerView.ViewHolder item)

Method to be called by subclasses when an add animation is being started.

final void dispatchChangeFinished(RecyclerView.ViewHolder item, boolean oldItem)

Method to be called by subclasses when a change animation is done.

final void dispatchChangeStarting(RecyclerView.ViewHolder item, boolean oldItem)

Method to be called by subclasses when a change animation is being started.

final void dispatchMoveFinished(RecyclerView.ViewHolder item)

Method to be called by subclasses when a move animation is done.

final void dispatchMoveStarting(RecyclerView.ViewHolder item)

Method to be called by subclasses when a move animation is being started.

final void dispatchRemoveFinished(RecyclerView.ViewHolder item)

Method to be called by subclasses when a remove animation is done.

final void dispatchRemoveStarting(RecyclerView.ViewHolder item)

Method to be called by subclasses when a remove animation is being started.

boolean getSupportsChangeAnimations()

Returns whether this ItemAnimator supports animations of change events.

void onAddFinished(RecyclerView.ViewHolder item)

Called when an add animation has ended on the given ViewHolder.

void onAddStarting(RecyclerView.ViewHolder item)

Called when an add animation is being started on the given ViewHolder.

void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem)

Called when a change animation has ended on the given ViewHolder.

void onChangeStarting(RecyclerView.ViewHolder item, boolean oldItem)

Called when a change animation is being started on the given ViewHolder.

void onMoveFinished(RecyclerView.ViewHolder item)

Called when a move animation has ended on the given ViewHolder.

void onMoveStarting(RecyclerView.ViewHolder item)

Called when a move animation is being started on the given ViewHolder.

void onRemoveFinished(RecyclerView.ViewHolder item)

Called when a remove animation has ended on the given ViewHolder.

void onRemoveStarting(RecyclerView.ViewHolder item)

Called when a remove animation is being started on the given ViewHolder.

void setSupportsChangeAnimations(boolean supportsChangeAnimations)

Sets whether this ItemAnimator supports animations of item change events.

Inherited methods

Public constructors

SimpleItemAnimator

public SimpleItemAnimator ()

Public methods

animateAdd

public abstract boolean animateAdd (RecyclerView.ViewHolder holder)

Called when an item is added to the RecyclerView. Implementors can choose whether and how to animate that change, but must always call dispatchAddFinished(RecyclerView.ViewHolder) when done, either immediately (if no animation will occur) or after the animation actually finishes. The return value indicates whether an animation has been set up and whether the ItemAnimator's