2018-07-30 04:07:02 +02:00
|
|
|
/*
|
2019-05-14 14:08:05 +02:00
|
|
|
* Copyright 2018 The Android Open Source Project
|
2018-07-30 04:07:02 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
package androidx.recyclerview.widget;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* <p>
|
2019-05-14 14:08:05 +02:00
|
|
|
* It uses {@link RecyclerView.ItemAnimator.ItemHolderInfo} to track the bounds information of the Views. If you would like
|
2016-03-16 13:26:32 +01:00
|
|
|
* to
|
|
|
|
* extend this class, you can override {@link #obtainHolderInfo()} method to provide your own info
|
2019-05-14 14:08:05 +02:00
|
|
|
* class that extends {@link RecyclerView.ItemAnimator.ItemHolderInfo}.
|
2016-03-16 13:26:32 +01:00
|
|
|
*/
|
2018-07-30 04:07:02 +02:00
|
|
|
public abstract class SimpleItemAnimator extends RecyclerView.ItemAnimator {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
private static final boolean DEBUG = false;
|
|
|
|
|
|
|
|
private static final String TAG = "SimpleItemAnimator";
|
|
|
|
|
|
|
|
boolean mSupportsChangeAnimations = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this ItemAnimator supports animations of change events.
|
|
|
|
*
|
|
|
|
* @return true if change animations are supported, false otherwise
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public boolean getSupportsChangeAnimations() {
|
|
|
|
return mSupportsChangeAnimations;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether this ItemAnimator supports animations of item change events.
|
|
|
|
* If you set this property to false, actions on the data set which change the
|
|
|
|
* contents of items will not be animated. What those animations do is left
|
|
|
|
* up to the discretion of the ItemAnimator subclass, in its
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)} implementation.
|
2016-03-16 13:26:32 +01:00
|
|
|
* The value of this property is true by default.
|
|
|
|
*
|
|
|
|
* @param supportsChangeAnimations true if change animations are supported by
|
|
|
|
* this ItemAnimator, false otherwise. If the property is false,
|
|
|
|
* the ItemAnimator
|
|
|
|
* will not receive a call to
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int,
|
2016-03-16 13:26:32 +01:00
|
|
|
* int)} when changes occur.
|
2019-05-14 14:08:05 +02:00
|
|
|
* @see RecyclerView.Adapter#notifyItemChanged(int)
|
|
|
|
* @see RecyclerView.Adapter#notifyItemRangeChanged(int, int)
|
2016-03-16 13:26:32 +01:00
|
|
|
*/
|
|
|
|
public void setSupportsChangeAnimations(boolean supportsChangeAnimations) {
|
|
|
|
mSupportsChangeAnimations = supportsChangeAnimations;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*
|
|
|
|
* @return True if change animations are not supported or the ViewHolder is invalid,
|
|
|
|
* false otherwise.
|
|
|
|
*
|
|
|
|
* @see #setSupportsChangeAnimations(boolean)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
|
|
|
|
return !mSupportsChangeAnimations || viewHolder.isInvalid();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public boolean animateDisappearance(@NonNull RecyclerView.ViewHolder viewHolder,
|
2016-03-16 13:26:32 +01:00
|
|
|
@NonNull ItemHolderInfo preLayoutInfo, @Nullable ItemHolderInfo postLayoutInfo) {
|
|
|
|
int oldLeft = preLayoutInfo.left;
|
|
|
|
int oldTop = preLayoutInfo.top;
|
|
|
|
View disappearingItemView = viewHolder.itemView;
|
|
|
|
int newLeft = postLayoutInfo == null ? disappearingItemView.getLeft() : postLayoutInfo.left;
|
|
|
|
int newTop = postLayoutInfo == null ? disappearingItemView.getTop() : postLayoutInfo.top;
|
|
|
|
if (!viewHolder.isRemoved() && (oldLeft != newLeft || oldTop != newTop)) {
|
|
|
|
disappearingItemView.layout(newLeft, newTop,
|
|
|
|
newLeft + disappearingItemView.getWidth(),
|
|
|
|
newTop + disappearingItemView.getHeight());
|
|
|
|
if (DEBUG) {
|
|
|
|
Log.d(TAG, "DISAPPEARING: " + viewHolder + " with view " + disappearingItemView);
|
|
|
|
}
|
|
|
|
return animateMove(viewHolder, oldLeft, oldTop, newLeft, newTop);
|
|
|
|
} else {
|
|
|
|
if (DEBUG) {
|
|
|
|
Log.d(TAG, "REMOVED: " + viewHolder + " with view " + disappearingItemView);
|
|
|
|
}
|
|
|
|
return animateRemove(viewHolder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public boolean animateAppearance(@NonNull RecyclerView.ViewHolder viewHolder,
|
2016-03-16 13:26:32 +01:00
|
|
|
@Nullable ItemHolderInfo preLayoutInfo, @NonNull ItemHolderInfo postLayoutInfo) {
|
|
|
|
if (preLayoutInfo != null && (preLayoutInfo.left != postLayoutInfo.left
|
|
|
|
|| preLayoutInfo.top != postLayoutInfo.top)) {
|
|
|
|
// slide items in if before/after locations differ
|
|
|
|
if (DEBUG) {
|
|
|
|
Log.d(TAG, "APPEARING: " + viewHolder + " with view " + viewHolder);
|
|
|
|
}
|
|
|
|
return animateMove(viewHolder, preLayoutInfo.left, preLayoutInfo.top,
|
|
|
|
postLayoutInfo.left, postLayoutInfo.top);
|
|
|
|
} else {
|
|
|
|
if (DEBUG) {
|
|
|
|
Log.d(TAG, "ADDED: " + viewHolder + " with view " + viewHolder);
|
|
|
|
}
|
|
|
|
return animateAdd(viewHolder);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public boolean animatePersistence(@NonNull RecyclerView.ViewHolder viewHolder,
|
2016-03-16 13:26:32 +01:00
|
|
|
@NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) {
|
|
|
|
if (preInfo.left != postInfo.left || preInfo.top != postInfo.top) {
|
|
|
|
if (DEBUG) {
|
2018-07-30 04:07:02 +02:00
|
|
|
Log.d(TAG, "PERSISTENT: " + viewHolder
|
|
|
|
+ " with view " + viewHolder.itemView);
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
return animateMove(viewHolder,
|
|
|
|
preInfo.left, preInfo.top, postInfo.left, postInfo.top);
|
|
|
|
}
|
|
|
|
dispatchMoveFinished(viewHolder);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public boolean animateChange(@NonNull RecyclerView.ViewHolder oldHolder, @NonNull RecyclerView.ViewHolder newHolder,
|
2016-03-16 13:26:32 +01:00
|
|
|
@NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) {
|
|
|
|
if (DEBUG) {
|
|
|
|
Log.d(TAG, "CHANGED: " + oldHolder + " with view " + oldHolder.itemView);
|
|
|
|
}
|
|
|
|
final int fromLeft = preInfo.left;
|
|
|
|
final int fromTop = preInfo.top;
|
|
|
|
final int toLeft, toTop;
|
|
|
|
if (newHolder.shouldIgnore()) {
|
|
|
|
toLeft = preInfo.left;
|
|
|
|
toTop = preInfo.top;
|
|
|
|
} else {
|
|
|
|
toLeft = postInfo.left;
|
|
|
|
toTop = postInfo.top;
|
|
|
|
}
|
|
|
|
return animateChange(oldHolder, newHolder, fromLeft, fromTop, toLeft, toTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an item is removed from the RecyclerView. Implementors can choose
|
|
|
|
* whether and how to animate that change, but must always call
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #dispatchRemoveFinished(RecyclerView.ViewHolder)} when done, either
|
2016-03-16 13:26:32 +01:00
|
|
|
* 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 {@link #runPendingAnimations()} method should be called at the
|
|
|
|
* next opportunity. This mechanism allows ItemAnimator to set up individual animations
|
2019-05-14 14:08:05 +02:00
|
|
|
* as separate calls to {@link #animateAdd(RecyclerView.ViewHolder) animateAdd()},
|
|
|
|
* {@link #animateMove(RecyclerView.ViewHolder, int, int, int, int) animateMove()},
|
|
|
|
* {@link #animateRemove(RecyclerView.ViewHolder) animateRemove()}, and
|
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)} come in one by one,
|
2016-03-16 13:26:32 +01:00
|
|
|
* then start the animations together in the later call to {@link #runPendingAnimations()}.
|
|
|
|
*
|
|
|
|
* <p>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.</p>
|
|
|
|
*
|
|
|
|
* @param holder The item that is being removed.
|
|
|
|
* @return true if a later call to {@link #runPendingAnimations()} is requested,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public abstract boolean animateRemove(RecyclerView.ViewHolder holder);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an item is added to the RecyclerView. Implementors can choose
|
|
|
|
* whether and how to animate that change, but must always call
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #dispatchAddFinished(RecyclerView.ViewHolder)} when done, either
|
2016-03-16 13:26:32 +01:00
|
|
|
* 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 {@link #runPendingAnimations()} method should be called at the
|
|
|
|
* next opportunity. This mechanism allows ItemAnimator to set up individual animations
|
2019-05-14 14:08:05 +02:00
|
|
|
* as separate calls to {@link #animateAdd(RecyclerView.ViewHolder) animateAdd()},
|
|
|
|
* {@link #animateMove(RecyclerView.ViewHolder, int, int, int, int) animateMove()},
|
|
|
|
* {@link #animateRemove(RecyclerView.ViewHolder) animateRemove()}, and
|
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)} come in one by one,
|
2016-03-16 13:26:32 +01:00
|
|
|
* then start the animations together in the later call to {@link #runPendingAnimations()}.
|
|
|
|
*
|
|
|
|
* <p>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.</p>
|
|
|
|
*
|
|
|
|
* @param holder The item that is being added.
|
|
|
|
* @return true if a later call to {@link #runPendingAnimations()} is requested,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public abstract boolean animateAdd(RecyclerView.ViewHolder holder);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an item is moved in the RecyclerView. Implementors can choose
|
|
|
|
* whether and how to animate that change, but must always call
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #dispatchMoveFinished(RecyclerView.ViewHolder)} when done, either
|
2016-03-16 13:26:32 +01:00
|
|
|
* 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 {@link #runPendingAnimations()} method should be called at the
|
|
|
|
* next opportunity. This mechanism allows ItemAnimator to set up individual animations
|
2019-05-14 14:08:05 +02:00
|
|
|
* as separate calls to {@link #animateAdd(RecyclerView.ViewHolder) animateAdd()},
|
|
|
|
* {@link #animateMove(RecyclerView.ViewHolder, int, int, int, int) animateMove()},
|
|
|
|
* {@link #animateRemove(RecyclerView.ViewHolder) animateRemove()}, and
|
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)} come in one by one,
|
2016-03-16 13:26:32 +01:00
|
|
|
* then start the animations together in the later call to {@link #runPendingAnimations()}.
|
|
|
|
*
|
|
|
|
* @param holder The item that is being moved.
|
|
|
|
* @return true if a later call to {@link #runPendingAnimations()} is requested,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public abstract boolean animateMove(RecyclerView.ViewHolder holder, int fromX, int fromY,
|
2016-03-16 13:26:32 +01:00
|
|
|
int toX, int toY);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an item is changed in the RecyclerView, as indicated by a call to
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link RecyclerView.Adapter#notifyItemChanged(int)} or
|
|
|
|
* {@link RecyclerView.Adapter#notifyItemRangeChanged(int, int)}.
|
2016-03-16 13:26:32 +01:00
|
|
|
* <p>
|
|
|
|
* Implementers can choose whether and how to animate changes, but must always call
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #dispatchChangeFinished(RecyclerView.ViewHolder, boolean)} for each non-null distinct ViewHolder,
|
2016-03-16 13:26:32 +01:00
|
|
|
* either immediately (if no animation will occur) or after the animation actually finishes.
|
|
|
|
* If the {@code oldHolder} is the same ViewHolder as the {@code newHolder}, you must call
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #dispatchChangeFinished(RecyclerView.ViewHolder, boolean)} once and only once. In that case, the
|
2016-03-16 13:26:32 +01:00
|
|
|
* second parameter of {@code dispatchChangeFinished} is ignored.
|
|
|
|
* <p>
|
|
|
|
* The return value indicates whether an animation has been set up and whether the
|
|
|
|
* ItemAnimator's {@link #runPendingAnimations()} method should be called at the
|
|
|
|
* next opportunity. This mechanism allows ItemAnimator to set up individual animations
|
2019-05-14 14:08:05 +02:00
|
|
|
* as separate calls to {@link #animateAdd(RecyclerView.ViewHolder) animateAdd()},
|
|
|
|
* {@link #animateMove(RecyclerView.ViewHolder, int, int, int, int) animateMove()},
|
|
|
|
* {@link #animateRemove(RecyclerView.ViewHolder) animateRemove()}, and
|
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)} come in one by one,
|
2016-03-16 13:26:32 +01:00
|
|
|
* then start the animations together in the later call to {@link #runPendingAnimations()}.
|
|
|
|
*
|
|
|
|
* @param oldHolder The original item that changed.
|
|
|
|
* @param newHolder The new item that was created with the changed content. Might be null
|
|
|
|
* @param fromLeft Left of the old view holder
|
|
|
|
* @param fromTop Top of the old view holder
|
|
|
|
* @param toLeft Left of the new view holder
|
|
|
|
* @param toTop Top of the new view holder
|
|
|
|
* @return true if a later call to {@link #runPendingAnimations()} is requested,
|
|
|
|
* false otherwise.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public abstract boolean animateChange(RecyclerView.ViewHolder oldHolder,
|
|
|
|
RecyclerView.ViewHolder newHolder, int fromLeft, int fromTop, int toLeft, int toTop);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a remove animation is done.
|
|
|
|
*
|
|
|
|
* @param item The item which has been removed
|
2019-05-14 14:08:05 +02:00
|
|
|
* @see RecyclerView.ItemAnimator#animateDisappearance(RecyclerView.ViewHolder, ItemHolderInfo,
|
2016-03-16 13:26:32 +01:00
|
|
|
* ItemHolderInfo)
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchRemoveFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onRemoveFinished(item);
|
|
|
|
dispatchAnimationFinished(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a move animation is done.
|
|
|
|
*
|
|
|
|
* @param item The item which has been moved
|
2019-05-14 14:08:05 +02:00
|
|
|
* @see RecyclerView.ItemAnimator#animateDisappearance(RecyclerView.ViewHolder, ItemHolderInfo,
|
2016-03-16 13:26:32 +01:00
|
|
|
* ItemHolderInfo)
|
2019-05-14 14:08:05 +02:00
|
|
|
* @see RecyclerView.ItemAnimator#animatePersistence(RecyclerView.ViewHolder, ItemHolderInfo, ItemHolderInfo)
|
|
|
|
*
|
|
|
|
* @see RecyclerView.ItemAnimator#animateAppearance(RecyclerView.ViewHolder, ItemHolderInfo, ItemHolderInfo)
|
2016-03-16 13:26:32 +01:00
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchMoveFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onMoveFinished(item);
|
|
|
|
dispatchAnimationFinished(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when an add animation is done.
|
|
|
|
*
|
|
|
|
* @param item The item which has been added
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchAddFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onAddFinished(item);
|
|
|
|
dispatchAnimationFinished(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a change animation is done.
|
|
|
|
*
|
|
|
|
* @param item The item which has been changed (this method must be called for
|
|
|
|
* each non-null ViewHolder passed into
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)}).
|
2016-03-16 13:26:32 +01:00
|
|
|
* @param oldItem true if this is the old item that was changed, false if
|
|
|
|
* it is the new item that replaced the old item.
|
2019-05-14 14:08:05 +02:00
|
|
|
* @see #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)
|
2016-03-16 13:26:32 +01:00
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onChangeFinished(item, oldItem);
|
|
|
|
dispatchAnimationFinished(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a remove animation is being started.
|
|
|
|
*
|
|
|
|
* @param item The item being removed
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchRemoveStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onRemoveStarting(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a move animation is being started.
|
|
|
|
*
|
|
|
|
* @param item The item being moved
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchMoveStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onMoveStarting(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when an add animation is being started.
|
|
|
|
*
|
|
|
|
* @param item The item being added
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchAddStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onAddStarting(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to be called by subclasses when a change animation is being started.
|
|
|
|
*
|
|
|
|
* @param item The item which has been changed (this method must be called for
|
|
|
|
* each non-null ViewHolder passed into
|
2019-05-14 14:08:05 +02:00
|
|
|
* {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int, int)}).
|
2016-03-16 13:26:32 +01:00
|
|
|
* @param oldItem true if this is the old item that was changed, false if
|
|
|
|
* it is the new item that replaced the old item.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public final void dispatchChangeStarting(RecyclerView.ViewHolder item, boolean oldItem) {
|
2016-03-16 13:26:32 +01:00
|
|
|
onChangeStarting(item, oldItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a remove animation is being started on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("UnusedParameters")
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onRemoveStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a remove animation has ended on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onRemoveFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an add animation is being started on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("UnusedParameters")
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onAddStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an add animation has ended on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onAddFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a move animation is being started on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("UnusedParameters")
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onMoveStarting(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a move animation has ended on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onMoveFinished(RecyclerView.ViewHolder item) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a change animation is being started on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
* @param oldItem true if this is the old item that was changed, false if
|
|
|
|
* it is the new item that replaced the old item.
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("UnusedParameters")
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onChangeStarting(RecyclerView.ViewHolder item, boolean oldItem) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a change animation has ended on the given ViewHolder.
|
|
|
|
* The default implementation does nothing. Subclasses may wish to override
|
|
|
|
* this method to handle any ViewHolder-specific operations linked to animation
|
|
|
|
* lifecycles.
|
|
|
|
*
|
|
|
|
* @param item The ViewHolder being animated.
|
|
|
|
* @param oldItem true if this is the old item that was changed, false if
|
|
|
|
* it is the new item that replaced the old item.
|
|
|
|
*/
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) {
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|