Google 致力于为黑人社区推动种族平等。查看具体举措

SimpleItemAnimator

abstract class SimpleItemAnimator : RecyclerView.ItemAnimator
kotlin.Any
   ↳ 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 obtainHolderInfo() method to provide your own info class that extends RecyclerView.ItemAnimator.ItemHolderInfo.

Summary

Inherited constants
Public constructors

A wrapper class for ItemAnimator that records View bounds and decides whether it should run move, change, add or remove animations.

Public methods
abstract Boolean

Called when an item is added to the RecyclerView.

open Boolean
animateAppearance(@NonNull viewHolder: RecyclerView.ViewHolder, @Nullable preLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo?, @NonNull postLayoutInfo: RecyclerView.ItemAnimator.ItemHolderInfo)

open Boolean

abstract Boolean
animateChange(oldHolder: RecyclerView.ViewHolder!, newHolder: RecyclerView.ViewHolder!, fromLeft: Int, fromTop: Int, toLeft: Int, toTop: Int)

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

open Boolean

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

Called when an item is moved in the RecyclerView.

open Boolean

abstract Boolean

Called when an item is removed from the RecyclerView.

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

open Boolean

Returns whether this ItemAnimator supports animations of change events.

open Unit

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

open Unit

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

open Unit

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

open Unit

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

open Unit

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

open Unit

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

open Unit

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

open Unit

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

open Unit
setSupportsChangeAnimations(supportsChangeAnimations: Boolean)

Sets whether this ItemAnimator supports animations of item change events.

Inherited functions

Public constructors

<init>

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 obtainHolderInfo() method to provide your own info class that extends RecyclerView.ItemAnimator.ItemHolderInfo.

Public methods

animateAdd

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

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 runPendingAnimations() method should be called at the next opportunity. This mechanism allows ItemAnimator to set up individual animations as separate calls to animateAdd(), animateMove(), animateRemove(), and animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int) come in one by one, then start the animations together in the later call to runPendingAnimations().

This method may also be called for appearing items which were already in the RecyclerView, but for which the system does not have enough information to animate them into view. In that case, the default animation for adding items is run on those items as well.

Parameters
holder RecyclerView.ViewHolder!: The item that is being added.
Return
Boolean true if a later call to runPendingAnimations() is requested, false otherwise.

animateAppearance

open fun animateAppearance(
    @NonNull viewHolder: