/* * Copyright (C) 2016 The Android Open Source Project * * 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. */ package android.support.transition; import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; import android.support.annotation.IdRes; import android.support.annotation.IntDef; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.RestrictTo; import android.support.v4.util.ArrayMap; import android.support.v4.util.LongSparseArray; import android.support.v4.view.ViewCompat; import android.util.Log; import android.util.SparseArray; import android.view.SurfaceView; import android.view.TextureView; import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.Spinner; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; /** * A Transition holds information about animations that will be run on its * targets during a scene change. Subclasses of this abstract class may * choreograph several child transitions ({@link TransitionSet} or they may * perform custom animations themselves. Any Transition has two main jobs: * (1) capture property values, and (2) play animations based on changes to * captured property values. A custom transition knows what property values * on View objects are of interest to it, and also knows how to animate * changes to those values. For example, the {@link Fade} transition tracks * changes to visibility-related properties and is able to construct and run * animations that fade items in or out based on changes to those properties. * *
Note: Transitions may not work correctly with either {@link SurfaceView} * or {@link TextureView}, due to the way that these views are displayed * on the screen. For SurfaceView, the problem is that the view is updated from * a non-UI thread, so changes to the view due to transitions (such as moving * and resizing the view) may be out of sync with the display inside those bounds. * TextureView is more compatible with transitions in general, but some * specific transitions (such as {@link Fade}) may not be compatible * with TextureView because they rely on {@link android.view.ViewOverlay} * functionality, which does not currently work with TextureView.
* *Unlike the platform version, this does not support declaration by XML resources.
*/ public abstract class Transition implements Cloneable { private static final String LOG_TAG = "Transition"; static final boolean DBG = false; /** * With {@link #setMatchOrder(int...)}, chooses to match by View instance. */ public static final int MATCH_INSTANCE = 0x1; private static final int MATCH_FIRST = MATCH_INSTANCE; /** * With {@link #setMatchOrder(int...)}, chooses to match by * {@link android.view.View#getTransitionName()}. Null names will not be matched. */ public static final int MATCH_NAME = 0x2; /** * With {@link #setMatchOrder(int...)}, chooses to match by * {@link android.view.View#getId()}. Negative IDs will not be matched. */ public static final int MATCH_ID = 0x3; /** * With {@link #setMatchOrder(int...)}, chooses to match by the {@link android.widget.Adapter} * item id. When {@link android.widget.Adapter#hasStableIds()} returns false, no match * will be made for items. */ public static final int MATCH_ITEM_ID = 0x4; private static final int MATCH_LAST = MATCH_ITEM_ID; /** @hide */ @RestrictTo(LIBRARY_GROUP) @IntDef({MATCH_INSTANCE, MATCH_NAME, MATCH_ID, MATCH_ITEM_ID}) @Retention(RetentionPolicy.SOURCE) public @interface MatchOrder { } private static final int[] DEFAULT_MATCH_ORDER = { MATCH_NAME, MATCH_INSTANCE, MATCH_ID, MATCH_ITEM_ID, }; private String mName = getClass().getName(); private long mStartDelay = -1; long mDuration = -1; private TimeInterpolator mInterpolator = null; ArrayListA transition does not need to override this method. However, not doing so * will mean that the cancellation logic outlined in the previous paragraph * will be skipped for that transition, possibly leading to artifacts as * old transitions and new transitions on the same targets run in parallel, * animating views toward potentially different end values.
* * @return An array of property names as described in the class documentation for * {@link TransitionValues}. The default implementation returnsnull
.
*/
@Nullable
public String[] getTransitionProperties() {
return null;
}
/**
* This method creates an animation that will be run for this transition
* given the information in the startValues and endValues structures captured
* earlier for the start and end scenes. Subclasses of Transition should override
* this method. The method should only be called by the transition system; it is
* not intended to be called from external classes.
*
* This method is called by the transition's parent (all the way up to the * topmost Transition in the hierarchy) with the sceneRoot and start/end * values that the transition may need to set up initial target values * and construct an appropriate animation. For example, if an overall * Transition is a {@link TransitionSet} consisting of several * child transitions in sequence, then some of the child transitions may * want to set initial values on target views prior to the overall * Transition commencing, to put them in an appropriate state for the * delay between that start and the child Transition start time. For * example, a transition that fades an item in may wish to set the starting * alpha value to 0, to avoid it blinking in prior to the transition * actually starting the animation. This is necessary because the scene * change that triggers the Transition will automatically set the end-scene * on all target views, so a Transition that wants to animate from a * different value should set that value prior to returning from this method.
* *Additionally, a Transition can perform logic to determine whether * the transition needs to run on the given target and start/end values. * For example, a transition that resizes objects on the screen may wish * to avoid running for views which are not present in either the start * or end scenes.
* *If there is an animator created and returned from this method, the
* transition mechanism will apply any applicable duration, startDelay,
* and interpolator to that animation and start it. A return value of
* null
indicates that no animation should run. The default
* implementation returns null.
The method is called for every applicable target object, which is * stored in the {@link TransitionValues#view} field.
* * @param sceneRoot The root of the transition hierarchy. * @param startValues The values for a specific target in the start scene. * @param endValues The values for the target in the end scene. * @return A Animator to be started at the appropriate time in the * overall transition for this scene change. A null value means no animation * should be run. */ @Nullable public Animator createAnimator(@NonNull ViewGroup sceneRoot, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues) { return null; } /** * Sets the order in which Transition matches View start and end values. ** The default behavior is to match first by {@link android.view.View#getTransitionName()}, * then by View instance, then by {@link android.view.View#getId()} and finally * by its item ID if it is in a direct child of ListView. The caller can * choose to have only some or all of the values of {@link #MATCH_INSTANCE}, * {@link #MATCH_NAME}, {@link #MATCH_ITEM_ID}, and {@link #MATCH_ID}. Only * the match algorithms supplied will be used to determine whether Views are the * the same in both the start and end Scene. Views that do not match will be considered * as entering or leaving the Scene. *
* * @param matches A list of zero or more of {@link #MATCH_INSTANCE}, * {@link #MATCH_NAME}, {@link #MATCH_ITEM_ID}, and {@link #MATCH_ID}. * If none are provided, then the default match order will be set. */ public void setMatchOrder(@MatchOrder int... matches) { if (matches == null || matches.length == 0) { mMatchOrder = DEFAULT_MATCH_ORDER; } else { for (int i = 0; i < matches.length; i++) { int match = matches[i]; if (!isValidMatch(match)) { throw new IllegalArgumentException("matches contains invalid value"); } if (alreadyContains(matches, i)) { throw new IllegalArgumentException("matches contains a duplicate value"); } } mMatchOrder = matches.clone(); } } private static boolean isValidMatch(int match) { return (match >= MATCH_FIRST && match <= MATCH_LAST); } private static boolean alreadyContains(int[] array, int searchIndex) { int value = array[searchIndex]; for (int i = 0; i < searchIndex; i++) { if (array[i] == value) { return true; } } return false; } /** * Match start/end values by View instance. Adds matched values to mStartValuesList * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd. */ private void matchInstances(ArrayMapSubclasses must implement this method. The method should only be called by the * transition system; it is not intended to be called from external classes.
* * @param transitionValues The holder for any values that the Transition * wishes to store. Values are stored in thevalues
field
* of this TransitionValues object and are keyed from
* a String value. For example, to store a view's rotation value,
* a transition might call
* transitionValues.values.put("appname:transitionname:rotation",
* view.getRotation())
. The target view will already be stored
* in
* the transitionValues structure when this method is called.
* @see #captureEndValues(TransitionValues)
* @see #createAnimator(ViewGroup, TransitionValues, TransitionValues)
*/
public abstract void captureStartValues(@NonNull TransitionValues transitionValues);
/**
* Captures the values in the end scene for the properties that this
* transition monitors. These values are then passed as the endValues
* structure in a later call to
* {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}.
* The main concern for an implementation is what the
* properties are that the transition cares about and what the values are
* for all of those properties. The start and end values will be compared
* later during the
* {@link #createAnimator(ViewGroup, TransitionValues, TransitionValues)}
* method to determine what, if any, animations, should be run.
*
* Subclasses must implement this method. The method should only be called by the * transition system; it is not intended to be called from external classes.
* * @param transitionValues The holder for any values that the Transition * wishes to store. Values are stored in thevalues
field
* of this TransitionValues object and are keyed from
* a String value. For example, to store a view's rotation value,
* a transition might call
* transitionValues.values.put("appname:transitionname:rotation",
* view.getRotation())
. The target view will already be stored
* in
* the transitionValues structure when this method is called.
* @see #captureStartValues(TransitionValues)
* @see #createAnimator(ViewGroup, TransitionValues, TransitionValues)
*/
public abstract void captureEndValues(@NonNull TransitionValues transitionValues);
/**
* Sets the target view instances that this Transition is interested in
* animating. By default, there are no targets, and a Transition will
* listen for changes on every view in the hierarchy below the sceneRoot
* of the Scene being transitioned into. Setting targets constrains
* the Transition to only listen for, and act on, these views.
* All other views will be ignored.
*
* The target list is like the {@link #addTarget(int) targetId} * list except this list specifies the actual View instances, not the ids * of the views. This is an important distinction when scene changes involve * view hierarchies which have been inflated separately; different views may * share the same id but not actually be the same instance. If the transition * should treat those views as the same, then {@link #addTarget(int)} should be used * instead of {@link #addTarget(View)}. If, on the other hand, scene changes involve * changes all within the same view hierarchy, among views which do not * necessarily have ids set on them, then the target list of views may be more * convenient.
* * @param target A View on which the Transition will act, must be non-null. * @return The Transition to which the target is added. * Returning the same object makes it easier to chain calls during * construction, such as *transitionSet.addTransitions(new Fade()).addTarget(someView);
* @see #addTarget(int)
*/
@NonNull
public Transition addTarget(@NonNull View target) {
mTargets.add(target);
return this;
}
/**
* Adds the id of a target view that this Transition is interested in
* animating. By default, there are no targetIds, and a Transition will
* listen for changes on every view in the hierarchy below the sceneRoot
* of the Scene being transitioned into. Setting targetIds constrains
* the Transition to only listen for, and act on, views with these IDs.
* Views with different IDs, or no IDs whatsoever, will be ignored.
*
* Note that using ids to specify targets implies that ids should be unique * within the view hierarchy underneath the scene root.
* * @param targetId The id of a target view, must be a positive number. * @return The Transition to which the targetId is added. * Returning the same object makes it easier to chain calls during * construction, such as *transitionSet.addTransitions(new Fade()).addTarget(someId);
* @see View#getId()
*/
@NonNull
public Transition addTarget(@IdRes int targetId) {
if (targetId > 0) {
mTargetIds.add(targetId);
}
return this;
}
/**
* Adds the transitionName of a target view that this Transition is interested in
* animating. By default, there are no targetNames, and a Transition will
* listen for changes on every view in the hierarchy below the sceneRoot
* of the Scene being transitioned into. Setting targetNames constrains
* the Transition to only listen for, and act on, views with these transitionNames.
* Views with different transitionNames, or no transitionName whatsoever, will be ignored.
*
* Note that transitionNames should be unique within the view hierarchy.
* * @param targetName The transitionName of a target view, must be non-null. * @return The Transition to which the target transitionName is added. * Returning the same object makes it easier to chain calls during * construction, such as *transitionSet.addTransitions(new Fade()).addTarget(someName);
* @see ViewCompat#getTransitionName(View)
*/
@NonNull
public Transition addTarget(@NonNull String targetName) {
if (mTargetNames == null) {
mTargetNames = new ArrayList<>();
}
mTargetNames.add(targetName);
return this;
}
/**
* Adds the Class of a target view that this Transition is interested in
* animating. By default, there are no targetTypes, and a Transition will
* listen for changes on every view in the hierarchy below the sceneRoot
* of the Scene being transitioned into. Setting targetTypes constrains
* the Transition to only listen for, and act on, views with these classes.
* Views with different classes will be ignored.
*
* Note that any View that can be cast to targetType will be included, so
* if targetType is View.class
, all Views will be included.
transitionSet.addTransitions(new Fade()).addTarget(ImageView.class);
* @see #addTarget(int)
* @see #addTarget(android.view.View)
* @see #excludeTarget(Class, boolean)
* @see #excludeChildren(Class, boolean)
*/
@NonNull
public Transition addTarget(@NonNull Class targetType) {
if (mTargetTypes == null) {
mTargetTypes = new ArrayList<>();
}
mTargetTypes.add(targetType);
return this;
}
/**
* Removes the given target from the list of targets that this Transition
* is interested in animating.
*
* @param target The target view, must be non-null.
* @return Transition The Transition from which the target is removed.
* Returning the same object makes it easier to chain calls during
* construction, such as
* transitionSet.addTransitions(new Fade()).removeTarget(someView);
*/
@NonNull
public Transition removeTarget(@NonNull View target) {
mTargets.remove(target);
return this;
}
/**
* Removes the given targetId from the list of ids that this Transition
* is interested in animating.
*
* @param targetId The id of a target view, must be a positive number.
* @return The Transition from which the targetId is removed.
* Returning the same object makes it easier to chain calls during
* construction, such as
* transitionSet.addTransitions(new Fade()).removeTargetId(someId);
*/
@NonNull
public Transition removeTarget(@IdRes int targetId) {
if (targetId > 0) {
mTargetIds.remove((Integer) targetId);
}
return this;
}
/**
* Removes the given targetName from the list of transitionNames that this Transition
* is interested in animating.
*
* @param targetName The transitionName of a target view, must not be null.
* @return The Transition from which the targetName is removed.
* Returning the same object makes it easier to chain calls during
* construction, such as
* transitionSet.addTransitions(new Fade()).removeTargetName(someName);
*/
@NonNull
public Transition removeTarget(@NonNull String targetName) {
if (mTargetNames != null) {
mTargetNames.remove(targetName);
}
return this;
}
/**
* Removes the given target from the list of targets that this Transition
* is interested in animating.
*
* @param target The type of the target view, must be non-null.
* @return Transition The Transition from which the target is removed.
* Returning the same object makes it easier to chain calls during
* construction, such as
* transitionSet.addTransitions(new Fade()).removeTarget(someType);
*/
@NonNull
public Transition removeTarget(@NonNull Class target) {
if (mTargetTypes != null) {
mTargetTypes.remove(target);
}
return this;
}
/**
* Utility method to manage the boilerplate code that is the same whether we
* are excluding targets or their children.
*/
private static exclude
parameter specifies whether the target
* should be added to or removed from the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param target The target to ignore when running this transition. * @param exclude Whether to add the target to or remove the target from the * current list of excluded targets. * @return This transition object. * @see #excludeChildren(View, boolean) * @see #excludeTarget(int, boolean) * @see #excludeTarget(Class, boolean) */ @NonNull public Transition excludeTarget(@NonNull View target, boolean exclude) { mTargetExcludes = excludeView(mTargetExcludes, target, exclude); return this; } /** * Whether to add the given id to the list of target ids to exclude from this * transition. Theexclude
parameter specifies whether the target
* should be added to or removed from the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param targetId The id of a target to ignore when running this transition. * @param exclude Whether to add the target to or remove the target from the * current list of excluded targets. * @return This transition object. * @see #excludeChildren(int, boolean) * @see #excludeTarget(View, boolean) * @see #excludeTarget(Class, boolean) */ @NonNull public Transition excludeTarget(@IdRes int targetId, boolean exclude) { mTargetIdExcludes = excludeId(mTargetIdExcludes, targetId, exclude); return this; } /** * Whether to add the given transitionName to the list of target transitionNames to exclude * from this transition. Theexclude
parameter specifies whether the target
* should be added to or removed from the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded by their * id, their instance reference, their transitionName, or by the Class of that view * (eg, {@link Spinner}).
* * @see #excludeTarget(View, boolean) * @see #excludeTarget(int, boolean) * @see #excludeTarget(Class, boolean) * * @param targetName The name of a target to ignore when running this transition. * @param exclude Whether to add the target to or remove the target from the * current list of excluded targets. * @return This transition object. */ @NonNull public Transition excludeTarget(@NonNull String targetName, boolean exclude) { mTargetNameExcludes = excludeObject(mTargetNameExcludes, targetName, exclude); return this; } /** * Whether to add the children of given target to the list of target children * to exclude from this transition. Theexclude
parameter specifies
* whether the target should be added to or removed from the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param target The target to ignore when running this transition. * @param exclude Whether to add the target to or remove the target from the * current list of excluded targets. * @return This transition object. * @see #excludeTarget(View, boolean) * @see #excludeChildren(int, boolean) * @see #excludeChildren(Class, boolean) */ @NonNull public Transition excludeChildren(@NonNull View target, boolean exclude) { mTargetChildExcludes = excludeView(mTargetChildExcludes, target, exclude); return this; } /** * Whether to add the children of the given id to the list of targets to exclude * from this transition. Theexclude
parameter specifies whether
* the children of the target should be added to or removed from the excluded list.
* Excluding children in this way provides a simple mechanism for excluding all
* children of specific targets, rather than individually excluding each
* child individually.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param targetId The id of a target whose children should be ignored when running * this transition. * @param exclude Whether to add the target to or remove the target from the * current list of excluded-child targets. * @return This transition object. * @see #excludeTarget(int, boolean) * @see #excludeChildren(View, boolean) * @see #excludeChildren(Class, boolean) */ @NonNull public Transition excludeChildren(@IdRes int targetId, boolean exclude) { mTargetIdChildExcludes = excludeId(mTargetIdChildExcludes, targetId, exclude); return this; } /** * Utility method to manage the boilerplate code that is the same whether we * are excluding targets or their children. */ private ArrayListexclude
parameter specifies whether the target
* type should be added to or removed from the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param type The type to ignore when running this transition. * @param exclude Whether to add the target type to or remove it from the * current list of excluded target types. * @return This transition object. * @see #excludeChildren(Class, boolean) * @see #excludeTarget(int, boolean) * @see #excludeTarget(View, boolean) */ @NonNull public Transition excludeTarget(@NonNull Class type, boolean exclude) { mTargetTypeExcludes = excludeType(mTargetTypeExcludes, type, exclude); return this; } /** * Whether to add the given type to the list of types whose children should * be excluded from this transition. Theexclude
parameter
* specifies whether the target type should be added to or removed from
* the excluded list.
*
* Excluding targets is a general mechanism for allowing transitions to run on * a view hierarchy while skipping target views that should not be part of * the transition. For example, you may want to avoid animating children * of a specific ListView or Spinner. Views can be excluded either by their * id, or by their instance reference, or by the Class of that view * (eg, {@link Spinner}).
* * @param type The type to ignore when running this transition. * @param exclude Whether to add the target type to or remove it from the * current list of excluded target types. * @return This transition object. * @see #excludeTarget(Class, boolean) * @see #excludeChildren(int, boolean) * @see #excludeChildren(View, boolean) */ @NonNull public Transition excludeChildren(@NonNull Class type, boolean exclude) { mTargetTypeChildExcludes = excludeType(mTargetTypeChildExcludes, type, exclude); return this; } /** * Utility method to manage the boilerplate code that is the same whether we * are excluding targets or their children. */ private ArrayListBy default, a Transition's name is simply the value of {@link Class#getName()}, * but subclasses are free to override and return something different.
* * @return The name of this transition. */ @NonNull public String getName() { return mName; } String toString(String indent) { String result = indent + getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) + ": "; if (mDuration != -1) { result += "dur(" + mDuration + ") "; } if (mStartDelay != -1) { result += "dly(" + mStartDelay + ") "; } if (mInterpolator != null) { result += "interp(" + mInterpolator + ") "; } if (mTargetIds.size() > 0 || mTargets.size() > 0) { result += "tgts("; if (mTargetIds.size() > 0) { for (int i = 0; i < mTargetIds.size(); ++i) { if (i > 0) { result += ", "; } result += mTargetIds.get(i); } } if (mTargets.size() > 0) { for (int i = 0; i < mTargets.size(); ++i) { if (i > 0) { result += ", "; } result += mTargets.get(i); } } result += ")"; } return result; } /** * A transition listener receives notifications from a transition. * Notifications indicate transition lifecycle events. */ public interface TransitionListener { /** * Notification about the start of the transition. * * @param transition The started transition. */ void onTransitionStart(@NonNull Transition transition); /** * Notification about the end of the transition. Canceled transitions * will always notify listeners of both the cancellation and end * events. That is, {@link #onTransitionEnd(Transition)} is always called, * regardless of whether the transition was canceled or played * through to completion. * * @param transition The transition which reached its end. */ void onTransitionEnd(@NonNull Transition transition); /** * Notification about the cancellation of the transition. * Note that cancel may be called by a parent {@link TransitionSet} on * a child transition which has not yet started. This allows the child * transition to restore state on target objects which was set at * {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues) * createAnimator()} time. * * @param transition The transition which was canceled. */ void onTransitionCancel(@NonNull Transition transition); /** * Notification when a transition is paused. * Note that createAnimator() may be called by a parent {@link TransitionSet} on * a child transition which has not yet started. This allows the child * transition to restore state on target objects which was set at * {@link #createAnimator(android.view.ViewGroup, TransitionValues, TransitionValues) * createAnimator()} time. * * @param transition The transition which was paused. */ void onTransitionPause(@NonNull Transition transition); /** * Notification when a transition is resumed. * Note that resume() may be called by a parent {@link TransitionSet} on * a child transition which has not yet started. This allows the child * transition to restore state which may have changed in an earlier call * to {@link #onTransitionPause(Transition)}. * * @param transition The transition which was resumed. */ void onTransitionResume(@NonNull Transition transition); } /** * Utility adapter class to avoid having to override all three methods * whenever someone just wants to listen for a single event. * * @hide */ @RestrictTo(LIBRARY_GROUP) public static class TransitionListenerAdapter implements TransitionListener { @Override public void onTransitionStart(@NonNull Transition transition) { } @Override public void onTransitionEnd(@NonNull Transition transition) { } @Override public void onTransitionCancel(@NonNull Transition transition) { } @Override public void onTransitionPause(@NonNull Transition transition) { } @Override public void onTransitionResume(@NonNull Transition transition) { } } /** * Holds information about each animator used when a new transition starts * while other transitions are still running to determine whether a running * animation should be canceled or a new animation noop'd. The structure holds * information about the state that an animation is going to, to be compared to * end state of a new animation. */ private static class AnimationInfo { View mView; String mName; TransitionValues mValues; WindowIdImpl mWindowId; Transition mTransition; AnimationInfo(View view, String name, Transition transition, WindowIdImpl windowId, TransitionValues values) { mView = view; mName = name; mValues = values; mWindowId = windowId; mTransition = transition; } } /** * Utility class for managing typed ArrayLists efficiently. In particular, this * can be useful for lists that we don't expect to be used often (eg, the exclude * lists), so we'd like to keep them nulled out by default. This causes the code to * become tedious, with constant null checks, code to allocate when necessary, * and code to null out the reference when the list is empty. This class encapsulates * all of that functionality into simple add()/remove() methods which perform the * necessary checks, allocation/null-out as appropriate, and return the * resulting list. */ private static class ArrayListManager { /** * Add the specified item to the list, returning the resulting list. * The returned list can either the be same list passed in or, if that * list was null, the new list that was created. * * Note that the list holds unique items; if the item already exists in the * list, the list is not modified. */ static