- 
                    
                    
 public abstract class RecyclerView.ItemAnimatorThis class defines the animations that take place on items as changes are madeto the adapter.Subclasses of ItemAnimator can be used to implement custom animations for actions onViewHolder items. The RecyclerView will manage retaining these items while theyare being animated, but implementors must call dispatchAnimationFinished when a ViewHolder's animation is finished. In other words, there must be a matching dispatchAnimationFinished call for each animateAppearance(), animateChange()animatePersistence(),and animateDisappearance() call. By default, RecyclerView uses DefaultItemAnimator. 
- 
                
                    
                    - 
                                
                            
                                Nested Class SummaryNested Classes Modifier and Type Class Description public @interfaceRecyclerView.ItemAnimator.AdapterChangesThe set of flags that might be passed to recordPreLayoutInformation. public interfaceRecyclerView.ItemAnimator.ItemAnimatorFinishedListenerThis interface is used to inform listeners when all pending or running animationsin an ItemAnimator are finished. This can be used, for example, to delay an actionin a data set until currently-running animations are complete. public classRecyclerView.ItemAnimator.ItemHolderInfoA simple data structure that holds information about an item's bounds.This information is used in calculating item animations. Default implementation of recordPreLayoutInformation and recordPostLayoutInformation returns this datastructure. You can extend this class if you would like to keep more information aboutthe Views. If you want to provide your own implementation but still use `super` methods to recordbasic information, you can override obtainHolderInfo to provide your owninstances. 
 - 
                                
                            
                                Field SummaryFields Modifier and Type Field Description public final static intFLAG_CHANGEDpublic final static intFLAG_REMOVEDpublic final static intFLAG_INVALIDATEDpublic final static intFLAG_MOVEDpublic final static intFLAG_APPEARED_IN_PRE_LAYOUT
 - 
                                
                            
                                Method SummaryModifier and Type Method Description longgetMoveDuration()Gets the current duration for which all move animations will run. voidsetMoveDuration(long moveDuration)Sets the duration for which all move animations will run. longgetAddDuration()Gets the current duration for which all add animations will run. voidsetAddDuration(long addDuration)Sets the duration for which all add animations will run. longgetRemoveDuration()Gets the current duration for which all remove animations will run. voidsetRemoveDuration(long removeDuration)Sets the duration for which all remove animations will run. longgetChangeDuration()Gets the current duration for which all change animations will run. voidsetChangeDuration(long changeDuration)Sets the duration for which all change animations will run. RecyclerView.ItemAnimator.ItemHolderInforecordPreLayoutInformation(@NonNull() RecyclerView.State state, @NonNull() RecyclerView.ViewHolder viewHolder, int changeFlags, @NonNull() List<Object> payloads)Called by the RecyclerView before the layout begins. RecyclerView.ItemAnimator.ItemHolderInforecordPostLayoutInformation(@NonNull() RecyclerView.State state, @NonNull() RecyclerView.ViewHolder viewHolder)Called by the RecyclerView after the layout is complete. abstract booleananimateDisappearance(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @Nullable() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)Called by the RecyclerView when a ViewHolder has disappeared from the layout. abstract booleananimateAppearance(@NonNull() RecyclerView.ViewHolder viewHolder, @Nullable() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)Called by the RecyclerView when a ViewHolder is added to the layout. abstract booleananimatePersistence(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)Called by the RecyclerView when a ViewHolder is present in both before and after thelayout and RecyclerView has not received a notifyItemChanged callfor it or a notifyDataSetChanged call. abstract booleananimateChange(@NonNull() RecyclerView.ViewHolder oldHolder, @NonNull() RecyclerView.ViewHolder newHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo)Called by the RecyclerView when an adapter item is present both before and after thelayout and RecyclerView has received a notifyItemChanged callfor it. abstract voidrunPendingAnimations()Called when there are pending animations waiting to be started. abstract voidendAnimation(@NonNull() RecyclerView.ViewHolder item)Method called when an animation on a view should be ended immediately.This could happen when other events, like scrolling, occur, so thatanimating views can be quickly put into their proper end locations.Implementations should ensure that any animations running on the itemare canceled and affected properties are set to their end values. abstract voidendAnimations()Method called when all item animations should be ended immediately.This could happen when other events, like scrolling, occur, so thatanimating views can be quickly put into their proper end locations.Implementations should ensure that any animations running on any itemsare canceled and affected properties are set to their end values. abstract booleanisRunning()Method which returns whether there are any item animations currently running.This method can be used to determine whether to delay other actions untilanimations end. final voiddispatchAnimationFinished(@NonNull() RecyclerView.ViewHolder viewHolder)Method to be called by subclasses when an animation is finished. voidonAnimationFinished(@NonNull() RecyclerView.ViewHolder viewHolder)Called after dispatchAnimationFinished is called by theItemAnimator. final voiddispatchAnimationStarted(@NonNull() RecyclerView.ViewHolder viewHolder)Method to be called by subclasses when an animation is started. voidonAnimationStarted(@NonNull() RecyclerView.ViewHolder viewHolder)Called when a new animation is started on the given ViewHolder. final booleanisRunning(@Nullable() RecyclerView.ItemAnimator.ItemAnimatorFinishedListener listener)Like isRunning, this method returns whether there are any itemanimations currently running. booleancanReuseUpdatedViewHolder(@NonNull() RecyclerView.ViewHolder viewHolder)When an item is changed, ItemAnimator can decide whether it wants to re-usethe same ViewHolder for animations or RecyclerView should create a copy of theitem and ItemAnimator will use both to run the animation (e.g. booleancanReuseUpdatedViewHolder(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() List<Object> payloads)When an item is changed, ItemAnimator can decide whether it wants to re-usethe same ViewHolder for animations or RecyclerView should create a copy of theitem and ItemAnimator will use both to run the animation (e.g. final voiddispatchAnimationsFinished()This method should be called by ItemAnimator implementations to notifyany listeners that all pending and active item animations are finished. RecyclerView.ItemAnimator.ItemHolderInfoobtainHolderInfo()Returns a new ItemHolderInfo which will be used to store information about theViewHolder. - 
                    
                    
                    
                    
                    - 
                                
                            
                                Method Detail- 
                                        getMoveDurationlong getMoveDuration() Gets the current duration for which all move animations will run. 
 - 
                                        setMoveDurationvoid setMoveDuration(long moveDuration) Sets the duration for which all move animations will run. - Parameters:
- moveDuration- The move duration
 
 - 
                                        getAddDurationlong getAddDuration() Gets the current duration for which all add animations will run. 
 - 
                                        setAddDurationvoid setAddDuration(long addDuration) Sets the duration for which all add animations will run. - Parameters:
- addDuration- The add duration
 
 - 
                                        getRemoveDurationlong getRemoveDuration() Gets the current duration for which all remove animations will run. 
 - 
                                        setRemoveDurationvoid setRemoveDuration(long removeDuration) Sets the duration for which all remove animations will run. - Parameters:
- removeDuration- The remove duration
 
 - 
                                        getChangeDurationlong getChangeDuration() Gets the current duration for which all change animations will run. 
 - 
                                        setChangeDurationvoid setChangeDuration(long changeDuration) Sets the duration for which all change animations will run. - Parameters:
- changeDuration- The change duration
 
 - 
                                        recordPreLayoutInformation@NonNull() RecyclerView.ItemAnimator.ItemHolderInfo recordPreLayoutInformation(@NonNull() RecyclerView.State state, @NonNull() RecyclerView.ViewHolder viewHolder, int changeFlags, @NonNull() List<Object> payloads) Called by the RecyclerView before the layout begins. Item animator should recordnecessary information about the View before it is potentially rebound, moved or removed. The data returned from this method will be passed to the related animate**methods.Note that this method may be called after pre-layout phase if LayoutManager adds newViews to the layout in pre-layout pass. The default implementation returns an ItemHolderInfo which holds the bounds ofthe View and the adapter change flags. - Parameters:
- state- The current State of RecyclerView which includes some useful dataabout the layout that will be calculated.
- viewHolder- The ViewHolder whose information should be recorded.
- changeFlags- Additional information about what changes happened in the Adapterabout the Item represented by this ViewHolder.
- payloads- The payload list that was previously passed tonotifyItemChanged ornotifyItemRangeChanged.
 
 - 
                                        recordPostLayoutInformation@NonNull() RecyclerView.ItemAnimator.ItemHolderInfo recordPostLayoutInformation(@NonNull() RecyclerView.State state, @NonNull() RecyclerView.ViewHolder viewHolder) Called by the RecyclerView after the layout is complete. Item animator should recordnecessary information about the View's final state. The data returned from this method will be passed to the related animate**methods.The default implementation returns an ItemHolderInfo which holds the bounds ofthe View. - Parameters:
- state- The current State of RecyclerView which includes some useful data aboutthe layout that will be calculated.
- viewHolder- The ViewHolder whose information should be recorded.
 
 - 
                                        animateDisappearanceabstract boolean animateDisappearance(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @Nullable() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo) Called by the RecyclerView when a ViewHolder has disappeared from the layout. This means that the View was a child of the LayoutManager when layout started but hasbeen removed by the LayoutManager. It might have been removed from the adapter or simplybecome invisible due to other factors. You can distinguish these two cases by checkingthe change flags that were passed to recordPreLayoutInformation. Note that when a ViewHolder both changes and disappears in the same layout pass, theanimation callback method which will be called by the RecyclerView depends on theItemAnimator's decision whether to re-use the same ViewHolder or not, and also theLayoutManager's decision whether to layout the changed version of a disappearingViewHolder or not. RecyclerView will call animateChange instead of {@code animateDisappearance}if and only if the ItemAnimatorreturns{@code false}from canReuseUpdatedViewHolder and theLayoutManager lays out a new disappearing view that holds the updated information.Built-in LayoutManagers try to avoid laying out updated versions of disappearing views.If LayoutManager supports predictive animations, it might provide a target disappearlocation for the View by laying it out in that location. When that happens,RecyclerView will call recordPostLayoutInformation and theresponse of that call will be passed to this method as the postLayoutInfo.ItemAnimator must call dispatchAnimationFinished when the animationis complete (or instantly call dispatchAnimationFinished if itdecides not to animate the view). - Parameters:
- viewHolder- The ViewHolder which should be animated
- preLayoutInfo- The information that was returned fromrecordPreLayoutInformation.
- postLayoutInfo- The information that was returned fromrecordPostLayoutInformation.
 
 - 
                                        animateAppearanceabstract boolean animateAppearance(@NonNull() RecyclerView.ViewHolder viewHolder, @Nullable() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo) Called by the RecyclerView when a ViewHolder is added to the layout. In detail, this means that the ViewHolder was not a child when the layout startedbut has been added by the LayoutManager. It might be newly added to the adapter orsimply become visible due to other factors. ItemAnimator must call dispatchAnimationFinished when the animationis complete (or instantly call dispatchAnimationFinished if itdecides not to animate the view). - Parameters:
- viewHolder- The ViewHolder which should be animated
- preLayoutInfo- The information that was returned fromrecordPreLayoutInformation.Might be null if Item was just added to the adapter orLayoutManager does not support predictive animations or it couldnot predict that this ViewHolder will become visible.
- postLayoutInfo- The information that was returned from .
 
 - 
                                        animatePersistenceabstract boolean animatePersistence(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo) Called by the RecyclerView when a ViewHolder is present in both before and after thelayout and RecyclerView has not received a notifyItemChanged callfor it or a notifyDataSetChanged call. This ViewHolder still represents the same data that it was representing when the layoutstarted but its position / size may be changed by the LayoutManager. If the Item's layout position didn't change, RecyclerView still calls this method becauseit does not track this information (or does not necessarily know that an animation isnot required). Your ItemAnimator should handle this case and if there is nothing toanimate, it should call dispatchAnimationFinished and return false.ItemAnimator must call dispatchAnimationFinished when the animationis complete (or instantly call dispatchAnimationFinished if itdecides not to animate the view). - Parameters:
- viewHolder- The ViewHolder which should be animated
- preLayoutInfo- The information that was returned fromrecordPreLayoutInformation.
- postLayoutInfo- The information that was returned from .
 
 - 
                                        animateChangeabstract boolean animateChange(@NonNull() RecyclerView.ViewHolder oldHolder, @NonNull() RecyclerView.ViewHolder newHolder, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo preLayoutInfo, @NonNull() RecyclerView.ItemAnimator.ItemHolderInfo postLayoutInfo) Called by the RecyclerView when an adapter item is present both before and after thelayout and RecyclerView has received a notifyItemChanged callfor it. This method may also be called when notifyDataSetChanged is called and adapter has stable ids so thatRecyclerView could still rebind views to the same ViewHolders. If viewType changes when notifyDataSetChanged is called, this method will not be called,instead, animateAppearance will becalled for the new ViewHolder and the old one will be recycled. If this method is called due to a notifyDataSetChanged call, there isa good possibility that item contents didn't really change but it is rebound from theadapter. DefaultItemAnimator will skip animating the View if its location on thescreen didn't change and your animator should handle this case as well and avoid creatingunnecessary animations. When an item is updated, ItemAnimator has a chance to ask RecyclerView to keep theprevious presentation of the item as-is and supply a new ViewHolder for the updatedpresentation (see: canReuseUpdatedViewHolder.This is useful if you don't know the contents of the Item and would liketo cross-fade the old and the new one (DefaultItemAnimator uses this technique). When you are writing a custom item animator for your layout, it might be more performantand elegant to re-use the same ViewHolder and animate the content changes manually. When notifyItemChanged is called, the Item's view type may change.If the Item's view type has changed or ItemAnimator returned falseforthis ViewHolder when canReuseUpdatedViewHolder was called, theoldHolderandnewHolderwill be different ViewHolder instanceswhich represent the same Item. In that case, only the new ViewHolder is visibleto the LayoutManager but RecyclerView keeps old ViewHolder attached for animations.ItemAnimator must call dispatchAnimationFinished for each distinctViewHolder when their animation is complete(or instantly call dispatchAnimationFinished if it decides not toanimate the view). If oldHolder and newHolder are the same instance, you should call dispatchAnimationFinishedonly once. Note that when a ViewHolder both changes and disappears in the same layout pass, theanimation callback method which will be called by the RecyclerView depends on theItemAnimator's decision whether to re-use the same ViewHolder or not, and also theLayoutManager's decision whether to layout the changed version of a disappearingViewHolder or not. RecyclerView will call {@code animateChange}instead of animateDisappearance if and only if the ItemAnimator returns{@code false}from canReuseUpdatedViewHolder and theLayoutManager lays out a new disappearing view that holds the updated information.Built-in LayoutManagers try to avoid laying out updated versions of disappearing views.- Parameters:
- oldHolder- The ViewHolder before the layout is started, might be the sameinstance with newHolder.
- newHolder- The ViewHolder after the layout is finished, might be the sameinstance with oldHolder.
- preLayoutInfo- The information that was returned fromrecordPreLayoutInformation.
- postLayoutInfo- The information that was returned from .
 
 - 
                                        runPendingAnimationsabstract void runPendingAnimations() Called when there are pending animations waiting to be started. This stateis governed by the return values from animateAppearance(), animateChange() animatePersistence(), and animateDisappearance(), which inform the RecyclerView that the ItemAnimator wants to becalled later to start the associated animations. runPendingAnimations() will be scheduledto be run on the next frame. 
 - 
                                        endAnimationabstract void endAnimation(@NonNull() RecyclerView.ViewHolder item) Method called when an animation on a view should be ended immediately.This could happen when other events, like scrolling, occur, so thatanimating views can be quickly put into their proper end locations.Implementations should ensure that any animations running on the itemare canceled and affected properties are set to their end values.Also, dispatchAnimationFinished should be called for each finishedanimation since the animations are effectively done when this method is called. - Parameters:
- item- The item for which an animation should be stopped.
 
 - 
                                        endAnimationsabstract void endAnimations() Method called when all item animations should be ended immediately.This could happen when other events, like scrolling, occur, so thatanimating views can be quickly put into their proper end locations.Implementations should ensure that any animations running on any itemsare canceled and affected properties are set to their end values.Also, dispatchAnimationFinished should be called for each finishedanimation since the animations are effectively done when this method is called. 
 - 
                                        isRunningabstract boolean isRunning() Method which returns whether there are any item animations currently running.This method can be used to determine whether to delay other actions untilanimations end. 
 - 
                                        dispatchAnimationFinishedfinal void dispatchAnimationFinished(@NonNull() RecyclerView.ViewHolder viewHolder) Method to be called by subclasses when an animation is finished. For each call RecyclerView makes to animateAppearance(), animatePersistence(), or animateDisappearance(), thereshouldbe a matching dispatchAnimationFinished call by the subclass. For animateChange(), subclass should call this method for both the oldHolderandnewHolder(if they are not the same instance).- Parameters:
- viewHolder- The ViewHolder whose animation is finished.
 
 - 
                                        onAnimationFinishedvoid onAnimationFinished(@NonNull() RecyclerView.ViewHolder viewHolder) Called after dispatchAnimationFinished is called by theItemAnimator. - Parameters:
- viewHolder- The ViewHolder whose animation is finished.
 
 - 
                                        dispatchAnimationStartedfinal void dispatchAnimationStarted(@NonNull() RecyclerView.ViewHolder viewHolder) Method to be called by subclasses when an animation is started. For each call RecyclerView makes to animateAppearance(), animatePersistence(), or animateDisappearance(), there should be a matching dispatchAnimationStarted call by the subclass. For animateChange(), subclass should call this method for both the oldHolderandnewHolder(if they are not the same instance).If your ItemAnimator decides not to animate a ViewHolder, it should call dispatchAnimationFinishedwithout calling dispatchAnimationStarted. - Parameters:
- viewHolder- The ViewHolder whose animation is starting.
 
 - 
                                        onAnimationStartedvoid onAnimationStarted(@NonNull() RecyclerView.ViewHolder viewHolder) Called when a new animation is started on the given ViewHolder. - Parameters:
- viewHolder- The ViewHolder which started animating.
 
 - 
                                        isRunningfinal boolean isRunning(@Nullable() RecyclerView.ItemAnimator.ItemAnimatorFinishedListener listener) Like isRunning, this method returns whether there are any itemanimations currently running. Additionally, the listener passed in will be calledwhen there are no item animations running, either immediately (before the methodreturns) if no animations are currently running, or when the currently runninganimations are finished. Note that the listener is transient - it is either called immediately and notstored at all, or stored only until it is called when running animationsare finished sometime later. - Parameters:
- listener- A listener to be called immediately if no animations are runningor later when currently-running animations have finished.
 
 - 
                                        canReuseUpdatedViewHolderboolean canReuseUpdatedViewHolder(@NonNull() RecyclerView.ViewHolder viewHolder) When an item is changed, ItemAnimator can decide whether it wants to re-usethe same ViewHolder for animations or RecyclerView should create a copy of theitem 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 sametype (getItemViewType). Otherwise, ItemAnimator will always receiveboth ViewHolders in the animateChange method. If your application is using change payloads, you can override canReuseUpdatedViewHolder to decide based on payloads. - Parameters:
- viewHolder- The ViewHolder which represents the changed item's old content.
 
 - 
                                        canReuseUpdatedViewHolderboolean canReuseUpdatedViewHolder(@NonNull() RecyclerView.ViewHolder viewHolder, @NonNull() List<Object> payloads) When an item is changed, ItemAnimator can decide whether it wants to re-usethe same ViewHolder for animations or RecyclerView should create a copy of theitem 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 sametype (getItemViewType). Otherwise, ItemAnimator will always receiveboth ViewHolders in the animateChange method. - Parameters:
- viewHolder- The ViewHolder which represents the changed item's old content.
- payloads- A non-null list of merged payloads that were sent with changenotifications.
 
 - 
                                        dispatchAnimationsFinishedfinal void dispatchAnimationsFinished() This method should be called by ItemAnimator implementations to notifyany listeners that all pending and active item animations are finished. 
 - 
                                        obtainHolderInfo@NonNull() RecyclerView.ItemAnimator.ItemHolderInfo obtainHolderInfo() Returns a new ItemHolderInfo which will be used to store information about theViewHolder. This information will later be passed into animate**methods.You can override this method if you want to extend ItemHolderInfo and provideyour own instances. 
 
- 
                                        
 
- 
                                
                            
                                
 
- 
                    
                    
                    
                    
                    
 
-