11e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas/*
21e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * Copyright (C) 2015 The Android Open Source Project
31e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas *
41e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * Licensed under the Apache License, Version 2.0 (the "License");
51e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * you may not use this file except in compliance with the License.
61e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * You may obtain a copy of the License at
71e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas *
81e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas *      http://www.apache.org/licenses/LICENSE-2.0
91e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas *
101e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * Unless required by applicable law or agreed to in writing, software
111e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * distributed under the License is distributed on an "AS IS" BASIS,
121e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * See the License for the specific language governing permissions and
141e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas * limitations under the License.
151e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas */
161e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas
17121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyarpackage android.support.v7.widget;
18121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
19e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyarimport android.support.annotation.NonNull;
20e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyarimport android.support.annotation.Nullable;
21121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyarimport android.support.v7.widget.RecyclerView.Adapter;
22121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyarimport android.support.v7.widget.RecyclerView.ItemAnimator.ItemHolderInfo;
231e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikasimport android.support.v7.widget.RecyclerView.ViewHolder;
24e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyarimport android.util.Log;
25e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyarimport android.view.View;
26121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
27121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar/**
28121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar * A wrapper class for ItemAnimator that records View bounds and decides whether it should run
29e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar * move, change, add or remove animations. This class also replicates the original ItemAnimator
30e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar * API.
31121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar * <p>
32e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar * It uses {@link ItemHolderInfo} to track the bounds information of the Views. If you would like
33e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar * to
34121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar * extend this class, you can override {@link #obtainHolderInfo()} method to provide your own info
35121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar * class that extends {@link ItemHolderInfo}.
36121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar */
371e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikaspublic abstract class SimpleItemAnimator extends RecyclerView.ItemAnimator {
38121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
39121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    private static final boolean DEBUG = false;
40121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
41121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    private static final String TAG = "SimpleItemAnimator";
42121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
43121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    boolean mSupportsChangeAnimations = true;
44121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
45121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
46121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Returns whether this ItemAnimator supports animations of change events.
47121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
48121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @return true if change animations are supported, false otherwise
49121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
50121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @SuppressWarnings("unused")
51121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public boolean getSupportsChangeAnimations() {
52121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        return mSupportsChangeAnimations;
53121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
54121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
55121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
56121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Sets whether this ItemAnimator supports animations of item change events.
57121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * If you set this property to false, actions on the data set which change the
58121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * contents of items will not be animated. What those animations do is left
59121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * up to the discretion of the ItemAnimator subclass, in its
60121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} implementation.
61121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The value of this property is true by default.
62121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
63e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @param supportsChangeAnimations true if change animations are supported by
64e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                                 this ItemAnimator, false otherwise. If the property is false,
65e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                                 the ItemAnimator
66e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                                 will not receive a call to
67e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                                 {@link #animateChange(ViewHolder, ViewHolder, int, int, int,
68e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                                 int)} when changes occur.
69121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @see Adapter#notifyItemChanged(int)
70121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @see Adapter#notifyItemRangeChanged(int, int)
71121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
72121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public void setSupportsChangeAnimations(boolean supportsChangeAnimations) {
73121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        mSupportsChangeAnimations = supportsChangeAnimations;
74121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
75121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
76abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar    /**
77abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     * {@inheritDoc}
78abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     *
79abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     * @return True if change animations are not supported or the ViewHolder is invalid,
80abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     * false otherwise.
81abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     *
82abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     * @see #setSupportsChangeAnimations(boolean)
83abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar     */
84121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @Override
85abea494886a17e7a51080ab5e9c2ca041c533353Yigit Boyar    public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
86121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        return !mSupportsChangeAnimations || viewHolder.isInvalid();
87121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
88121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
89121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @Override
90e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public boolean animateDisappearance(@NonNull ViewHolder viewHolder,
91e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar            @NonNull ItemHolderInfo preLayoutInfo, @Nullable ItemHolderInfo postLayoutInfo) {
92121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        int oldLeft = preLayoutInfo.left;
93121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        int oldTop = preLayoutInfo.top;
94121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        View disappearingItemView = viewHolder.itemView;
95e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar        int newLeft = postLayoutInfo == null ? disappearingItemView.getLeft() : postLayoutInfo.left;
96e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar        int newTop = postLayoutInfo == null ? disappearingItemView.getTop() : postLayoutInfo.top;
97121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        if (!viewHolder.isRemoved() && (oldLeft != newLeft || oldTop != newTop)) {
98121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            disappearingItemView.layout(newLeft, newTop,
99121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                    newLeft + disappearingItemView.getWidth(),
100121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                    newTop + disappearingItemView.getHeight());
101121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            if (DEBUG) {
102121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                Log.d(TAG, "DISAPPEARING: " + viewHolder + " with view " + disappearingItemView);
103121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            }
104121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            return animateMove(viewHolder, oldLeft, oldTop, newLeft, newTop);
105121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        } else {
106121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            if (DEBUG) {
107121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                Log.d(TAG, "REMOVED: " + viewHolder + " with view " + disappearingItemView);
108121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            }
109121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            return animateRemove(viewHolder);
110121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        }
111121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
112121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
113121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @Override
114e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public boolean animateAppearance(@NonNull ViewHolder viewHolder,
115e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar            @Nullable ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
116e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar        if (preLayoutInfo != null && (preLayoutInfo.left != postLayoutInfo.left
117121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                || preLayoutInfo.top != postLayoutInfo.top)) {
118121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            // slide items in if before/after locations differ
119121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            if (DEBUG) {
120121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                Log.d(TAG, "APPEARING: " + viewHolder + " with view " + viewHolder);
121121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            }
122121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            return animateMove(viewHolder, preLayoutInfo.left, preLayoutInfo.top,
123121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                    postLayoutInfo.left, postLayoutInfo.top);
124121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        } else {
125121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            if (DEBUG) {
126121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                Log.d(TAG, "ADDED: " + viewHolder + " with view " + viewHolder);
127121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            }
128121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            return animateAdd(viewHolder);
129121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        }
130121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
131121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
132121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @Override
133e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public boolean animatePersistence(@NonNull ViewHolder viewHolder,
134e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar            @NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) {
135121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        if (preInfo.left != postInfo.left || preInfo.top != postInfo.top) {
136121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            if (DEBUG) {
1371e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas                Log.d(TAG, "PERSISTENT: " + viewHolder
1381e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas                        + " with view " + viewHolder.itemView);
139121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            }
140121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            return animateMove(viewHolder,
141121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar                    preInfo.left, preInfo.top, postInfo.left, postInfo.top);
142121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        }
143121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        dispatchMoveFinished(viewHolder);
144121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        return false;
145121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
146121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
147121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @Override
148e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public boolean animateChange(@NonNull ViewHolder oldHolder, @NonNull ViewHolder newHolder,
149e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar            @NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) {
150121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        if (DEBUG) {
151121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            Log.d(TAG, "CHANGED: " + oldHolder + " with view " + oldHolder.itemView);
152121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        }
153121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        final int fromLeft = preInfo.left;
154121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        final int fromTop = preInfo.top;
155121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        final int toLeft, toTop;
156e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar        if (newHolder.shouldIgnore()) {
157121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            toLeft = preInfo.left;
158121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            toTop = preInfo.top;
159121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        } else {
160121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            toLeft = postInfo.left;
161121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            toTop = postInfo.top;
162121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        }
163121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        return animateChange(oldHolder, newHolder, fromLeft, fromTop, toLeft, toTop);
164121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
165121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
166121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
167121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an item is removed from the RecyclerView. Implementors can choose
168121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * whether and how to animate that change, but must always call
169121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #dispatchRemoveFinished(ViewHolder)} when done, either
170121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * immediately (if no animation will occur) or after the animation actually finishes.
171121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The return value indicates whether an animation has been set up and whether the
172121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * ItemAnimator's {@link #runPendingAnimations()} method should be called at the
173121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * next opportunity. This mechanism allows ItemAnimator to set up individual animations
174121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * as separate calls to {@link #animateAdd(ViewHolder) animateAdd()},
175121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateMove(ViewHolder, int, int, int, int) animateMove()},
176121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateRemove(ViewHolder) animateRemove()}, and
177121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} come in one by one,
178121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * then start the animations together in the later call to {@link #runPendingAnimations()}.
179121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
180121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * <p>This method may also be called for disappearing items which continue to exist in the
181121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * RecyclerView, but for which the system does not have enough information to animate
182121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * them out of view. In that case, the default animation for removing items is run
183121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * on those items as well.</p>
184121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
185121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param holder The item that is being removed.
186121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @return true if a later call to {@link #runPendingAnimations()} is requested,
187121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * false otherwise.
188121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
1891e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas    public abstract boolean animateRemove(ViewHolder holder);
190121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
191121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
192121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an item is added to the RecyclerView. Implementors can choose
193121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * whether and how to animate that change, but must always call
194121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #dispatchAddFinished(ViewHolder)} when done, either
195121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * immediately (if no animation will occur) or after the animation actually finishes.
196121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The return value indicates whether an animation has been set up and whether the
197121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * ItemAnimator's {@link #runPendingAnimations()} method should be called at the
198121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * next opportunity. This mechanism allows ItemAnimator to set up individual animations
199121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * as separate calls to {@link #animateAdd(ViewHolder) animateAdd()},
200121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateMove(ViewHolder, int, int, int, int) animateMove()},
201121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateRemove(ViewHolder) animateRemove()}, and
202121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} come in one by one,
203121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * then start the animations together in the later call to {@link #runPendingAnimations()}.
204121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
205121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * <p>This method may also be called for appearing items which were already in the
206121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * RecyclerView, but for which the system does not have enough information to animate
207121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * them into view. In that case, the default animation for adding items is run
208121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * on those items as well.</p>
209121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
210121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param holder The item that is being added.
211121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @return true if a later call to {@link #runPendingAnimations()} is requested,
212121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * false otherwise.
213121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
2141e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas    public abstract boolean animateAdd(ViewHolder holder);
215121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
216121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
217121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an item is moved in the RecyclerView. Implementors can choose
218121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * whether and how to animate that change, but must always call
219121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #dispatchMoveFinished(ViewHolder)} when done, either
220121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * immediately (if no animation will occur) or after the animation actually finishes.
221121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The return value indicates whether an animation has been set up and whether the
222121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * ItemAnimator's {@link #runPendingAnimations()} method should be called at the
223121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * next opportunity. This mechanism allows ItemAnimator to set up individual animations
224121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * as separate calls to {@link #animateAdd(ViewHolder) animateAdd()},
225121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateMove(ViewHolder, int, int, int, int) animateMove()},
226121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateRemove(ViewHolder) animateRemove()}, and
227121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} come in one by one,
228121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * then start the animations together in the later call to {@link #runPendingAnimations()}.
229121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
230121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param holder The item that is being moved.
231121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @return true if a later call to {@link #runPendingAnimations()} is requested,
232121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * false otherwise.
233121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
2341e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas    public abstract boolean animateMove(ViewHolder holder, int fromX, int fromY,
235121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            int toX, int toY);
236121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
237121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
238121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an item is changed in the RecyclerView, as indicated by a call to
239121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link Adapter#notifyItemChanged(int)} or
240121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link Adapter#notifyItemRangeChanged(int, int)}.
241121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * <p>
242121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Implementers can choose whether and how to animate changes, but must always call
24379f19550856a1e90f90f1c103c404b6163e92c0fYigit Boyar     * {@link #dispatchChangeFinished(ViewHolder, boolean)} for each non-null distinct ViewHolder,
244121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * either immediately (if no animation will occur) or after the animation actually finishes.
24579f19550856a1e90f90f1c103c404b6163e92c0fYigit Boyar     * If the {@code oldHolder} is the same ViewHolder as the {@code newHolder}, you must call
24679f19550856a1e90f90f1c103c404b6163e92c0fYigit Boyar     * {@link #dispatchChangeFinished(ViewHolder, boolean)} once and only once. In that case, the
24779f19550856a1e90f90f1c103c404b6163e92c0fYigit Boyar     * second parameter of {@code dispatchChangeFinished} is ignored.
24879f19550856a1e90f90f1c103c404b6163e92c0fYigit Boyar     * <p>
249121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The return value indicates whether an animation has been set up and whether the
250121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * ItemAnimator's {@link #runPendingAnimations()} method should be called at the
251121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * next opportunity. This mechanism allows ItemAnimator to set up individual animations
252121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * as separate calls to {@link #animateAdd(ViewHolder) animateAdd()},
253121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateMove(ViewHolder, int, int, int, int) animateMove()},
254121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateRemove(ViewHolder) animateRemove()}, and
255121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)} come in one by one,
256121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * then start the animations together in the later call to {@link #runPendingAnimations()}.
257121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
258121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param oldHolder The original item that changed.
259121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param newHolder The new item that was created with the changed content. Might be null
260121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param fromLeft  Left of the old view holder
261121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param fromTop   Top of the old view holder
262121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param toLeft    Left of the new view holder
263121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param toTop     Top of the new view holder
264121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @return true if a later call to {@link #runPendingAnimations()} is requested,
265121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * false otherwise.
266121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
2671e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas    public abstract boolean animateChange(ViewHolder oldHolder,
268121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar            ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop);
269121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
270121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
271121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a remove animation is done.
272121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
273121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item which has been removed
274e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @see RecyclerView.ItemAnimator#animateDisappearance(ViewHolder, ItemHolderInfo,
275e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * ItemHolderInfo)
276121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
277121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchRemoveFinished(ViewHolder item) {
278121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onRemoveFinished(item);
279121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        dispatchAnimationFinished(item);
280121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
281121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
282121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
283121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a move animation is done.
284121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
285121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item which has been moved
286e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @see RecyclerView.ItemAnimator#animateDisappearance(ViewHolder, ItemHolderInfo,
287e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * ItemHolderInfo)
288121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @see RecyclerView.ItemAnimator#animatePersistence(ViewHolder, ItemHolderInfo, ItemHolderInfo)
289121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @see RecyclerView.ItemAnimator#animateAppearance(ViewHolder, ItemHolderInfo, ItemHolderInfo)
290121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
291121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchMoveFinished(ViewHolder item) {
292121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onMoveFinished(item);
293121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        dispatchAnimationFinished(item);
294121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
295121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
296121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
297121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when an add animation is done.
298121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
299121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item which has been added
300121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
301121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchAddFinished(ViewHolder item) {
302121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onAddFinished(item);
303121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        dispatchAnimationFinished(item);
304121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
305121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
306121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
307121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a change animation is done.
308121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
309e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @param item    The item which has been changed (this method must be called for
310e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                each non-null ViewHolder passed into
311e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)}).
312121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param oldItem true if this is the old item that was changed, false if
313e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                it is the new item that replaced the old item.
314e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @see #animateChange(ViewHolder, ViewHolder, int, int, int, int)
315121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
316121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchChangeFinished(ViewHolder item, boolean oldItem) {
317121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onChangeFinished(item, oldItem);
318121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        dispatchAnimationFinished(item);
319121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
320121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
321121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
322121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a remove animation is being started.
323121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
324121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item being removed
325121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
326121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchRemoveStarting(ViewHolder item) {
327121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onRemoveStarting(item);
328121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
329121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
330121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
331121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a move animation is being started.
332121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
333121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item being moved
334121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
335121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchMoveStarting(ViewHolder item) {
336121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onMoveStarting(item);
337121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
338121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
339121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
340121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when an add animation is being started.
341121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
342121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The item being added
343121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
344121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchAddStarting(ViewHolder item) {
345121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onAddStarting(item);
346121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
347121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
348121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
349121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Method to be called by subclasses when a change animation is being started.
350121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
351e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @param item    The item which has been changed (this method must be called for
352e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                each non-null ViewHolder passed into
353e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                {@link #animateChange(ViewHolder, ViewHolder, int, int, int, int)}).
354121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param oldItem true if this is the old item that was changed, false if
355e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                it is the new item that replaced the old item.
356121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
357121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    public final void dispatchChangeStarting(ViewHolder item, boolean oldItem) {
358121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar        onChangeStarting(item, oldItem);
359121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    }
360121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
361121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
362121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a remove animation is being started on the given ViewHolder.
363121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
364121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
365121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
366121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
367121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
368121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
369121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @SuppressWarnings("UnusedParameters")
370e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onRemoveStarting(ViewHolder item) {
371e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
372121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
373121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
374121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a remove animation has ended on the given ViewHolder.
375121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
376121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
377121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
378121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
379121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
380121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
381e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onRemoveFinished(ViewHolder item) {
382e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
383121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
384121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
385121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an add animation is being started on the given ViewHolder.
386121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
387121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
388121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
389121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
390121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
391121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
392121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @SuppressWarnings("UnusedParameters")
393e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onAddStarting(ViewHolder item) {
394e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
395121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
396121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
397121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when an add animation has ended on the given ViewHolder.
398121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
399121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
400121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
401121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
402121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
403121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
404e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onAddFinished(ViewHolder item) {
405e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
406121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
407121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
408121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a move animation is being started on the given ViewHolder.
409121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
410121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
411121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
412121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
413121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
414121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
415121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @SuppressWarnings("UnusedParameters")
416e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onMoveStarting(ViewHolder item) {
417e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
418121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
419121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
420121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a move animation has ended on the given ViewHolder.
421121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
422121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
423121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
424121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
425121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param item The ViewHolder being animated.
426121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
427e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onMoveFinished(ViewHolder item) {
428e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
429121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
430121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
431121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a change animation is being started on the given ViewHolder.
432121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
433121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
434121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
435121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
436e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @param item    The ViewHolder being animated.
437121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param oldItem true if this is the old item that was changed, false if
438e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                it is the new item that replaced the old item.
439121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
440121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    @SuppressWarnings("UnusedParameters")
441e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onChangeStarting(ViewHolder item, boolean oldItem) {
442e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
443121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar
444121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar    /**
445121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * Called when a change animation has ended on the given ViewHolder.
446121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * The default implementation does nothing. Subclasses may wish to override
447121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * this method to handle any ViewHolder-specific operations linked to animation
448121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * lifecycles.
449121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     *
450e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     * @param item    The ViewHolder being animated.
451121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     * @param oldItem true if this is the old item that was changed, false if
452e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar     *                it is the new item that replaced the old item.
453121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar     */
454e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    public void onChangeFinished(ViewHolder item, boolean oldItem) {
455e09e0b4ea04b6b6b0ef6c62979e8abdead0bf378Yigit Boyar    }
456121ba9616e5bed44d2490f1744f7b6a9d3e79866Yigit Boyar}
4571e827caa16440590647019b9c1338f6309c5be7aAurimas Liutikas
458