java.lang.Object | |
↳ | android.support.v7.widget.RecyclerView.ItemAnimator |
Known Direct Subclasses |
This class defines the animations that take place on items as changes are made
to the adapter.
Subclasses of ItemAnimator can be used to implement custom animations for actions on
ViewHolder items. The RecyclerView will manage retaining these items while they
are being animated, but implementors must call the appropriate "Finished"
method when each item animation is done (dispatchRemoveFinished(ViewHolder)
,
dispatchMoveFinished(ViewHolder)
, or dispatchAddFinished(ViewHolder)
).
By default, RecyclerView uses DefaultItemAnimator
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RecyclerView.ItemAnimator.ItemAnimatorFinishedListener | This interface is used to inform listeners when all pending or running animations in an ItemAnimator are finished. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Called when an item is added to the RecyclerView.
| |||||||||||
Called when an item is moved in the RecyclerView.
| |||||||||||
Called when an item is removed from the RecyclerView.
| |||||||||||
Method to be called by subclasses when an add animation is done.
| |||||||||||
This method should be called by ItemAnimator implementations to notify
any listeners that all pending and active item animations are finished.
| |||||||||||
Method to be called by subclasses when a move animation is done.
| |||||||||||
Method to be called by subclasses when a remove animation is done.
| |||||||||||
Method called when an animation on a view should be ended immediately.
| |||||||||||
Method called when all item animations should be ended immediately.
| |||||||||||
Gets the current duration for which all add animations will run.
| |||||||||||
Gets the current duration for which all move animations will run.
| |||||||||||
Gets the current duration for which all remove animations will run.
| |||||||||||
Like
isRunning() , this method returns whether there are any item
animations currently running. | |||||||||||
Method which returns whether there are any item animations currently running.
| |||||||||||
Called when there are pending animations waiting to be started.
| |||||||||||
Sets the current duration for which all add animations will run.
| |||||||||||
Sets the current duration for which all move animations will run.
| |||||||||||
Sets the current duration for which all remove animations will run.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Called when an item is added to the RecyclerView. Implementors can choose
whether and how to animate that change, but must always call
dispatchAddFinished(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
ItemAnimators runPendingAnimations()
method should be called at the
next opportunity. This mechanism allows ItemAnimator to set up individual animations
as separate calls to animateAdd()
,
animateMove()
, and
animateRemove()
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.
holder | The item that is being added. |
---|
runPendingAnimations()
is requested,
false otherwise.
Called when an item is moved in the RecyclerView. Implementors can choose
whether and how to animate that change, but must always call
dispatchMoveFinished(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
ItemAnimators runPendingAnimations()
method should be called at the
next opportunity. This mechanism allows ItemAnimator to set up individual animations
as separate calls to animateAdd()
,
animateMove()
, and
animateRemove()
come in one by one, then
start the animations together in the later call to runPendingAnimations()
.
holder | The item that is being moved. |
---|
runPendingAnimations()
is requested,
false otherwise.
Called when an item is removed from the RecyclerView. Implementors can choose
whether and how to animate that change, but must always call
dispatchRemoveFinished(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
ItemAnimators runPendingAnimations()
method should be called at the
next opportunity. This mechanism allows ItemAnimator to set up individual animations
as separate calls to animateAdd()
,
animateMove()
, and
animateRemove()
come in one by one, then
start the animations together in the later call to runPendingAnimations()
.
This method may also be called for disappearing items which continue to exist in the RecyclerView, but for which the system does not have enough information to animate them out of view. In that case, the default animation for removing items is run on those items as well.
holder | The item that is being removed. |
---|
runPendingAnimations()
is requested,
false otherwise.
Method to be called by subclasses when an add animation is done.
item | The item which has been added |
---|
This method should be called by ItemAnimator implementations to notify any listeners that all pending and active item animations are finished.
Method to be called by subclasses when a move animation is done.
item | The item which has been moved |
---|
Method to be called by subclasses when a remove animation is done.
item | The item which has been removed |
---|
Method called when an animation on a view should be ended immediately.
This could happen when other events, like scrolling, occur, so that
animating views can be quickly put into their proper end locations.
Implementations should ensure that any animations running on the item
are canceled and affected properties are set to their end values.
Also, appropriate dispatch methods (e.g., dispatchAddFinished(ViewHolder)
should be called since the animations are effectively done when this
method is called.
item | The item for which an animation should be stopped. |
---|
Method called when all item animations should be ended immediately.
This could happen when other events, like scrolling, occur, so that
animating views can be quickly put into their proper end locations.
Implementations should ensure that any animations running on any items
are canceled and affected properties are set to their end values.
Also, appropriate dispatch methods (e.g., dispatchAddFinished(ViewHolder)
should be called since the animations are effectively done when this
method is called.
Gets the current duration for which all add animations will run.
Gets the current duration for which all move animations will run.
Gets the current duration for which all remove animations will run.
Like isRunning()
, this method returns whether there are any item
animations currently running. Addtionally, the listener passed in will be called
when there are no item animations running, either immediately (before the method
returns) if no animations are currently running, or when the currently running
animations are finished
.
Note that the listener is transient - it is either called immediately and not stored at all, or stored only until it is called when running animations are finished sometime later.
listener | A listener to be called immediately if no animations are running
or later when currently-running animations have finished. A null listener is
equivalent to calling isRunning() . |
---|
Method which returns whether there are any item animations currently running. This method can be used to determine whether to delay other actions until animations end.
Called when there are pending animations waiting to be started. This state
is governed by the return values from animateAdd()
,
animateMove()
, and
animateRemove()
, which inform the
RecyclerView that the ItemAnimator wants to be called later to start the
associated animations. runPendingAnimations() will be scheduled to be run
on the next frame.
Sets the current duration for which all add animations will run.
addDuration | The current add duration |
---|
Sets the current duration for which all move animations will run.
moveDuration | The current move duration |
---|
Sets the current duration for which all remove animations will run.
removeDuration | The current remove duration |
---|