Loading core/java/android/animation/Animator.java +16 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,22 @@ public abstract class Animator implements Cloneable { public void setTarget(Object target) { } // Hide reverse() and canReverse() for now since reverse() only work for simple // cases, like we don't support sequential, neither startDelay. // TODO: make reverse() works for all the Animators. /** * @hide */ public boolean canReverse() { return false; } /** * @hide */ public void reverse() { } /** * <p>An animation listener receives notifications from an animation. * Notifications indicate animation related events, such as the end or the Loading core/java/android/animation/AnimatorSet.java +39 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public final class AnimatorSet extends Animator { // was set on this AnimatorSet, so it should not be passed down to the children. private TimeInterpolator mInterpolator = null; private boolean mReversible = true; /** * Sets up this AnimatorSet to play all of the supplied animations at the same time. * This is equivalent to calling {@link #play(Animator)} with the first animator in the Loading Loading @@ -177,6 +177,7 @@ public final class AnimatorSet extends Animator { if (items.length == 1) { play(items[0]); } else { mReversible = false; for (int i = 0; i < items.length - 1; ++i) { play(items[i]).before(items[i+1]); } Loading @@ -196,6 +197,7 @@ public final class AnimatorSet extends Animator { if (items.size() == 1) { play(items.get(0)); } else { mReversible = false; for (int i = 0; i < items.size() - 1; ++i) { play(items.get(i)).before(items.get(i+1)); } Loading Loading @@ -407,6 +409,9 @@ public final class AnimatorSet extends Animator { */ @Override public void setStartDelay(long startDelay) { if (mStartDelay > 0) { mReversible = false; } mStartDelay = startDelay; } Loading Loading @@ -626,6 +631,7 @@ public final class AnimatorSet extends Animator { anim.mNodeMap = new HashMap<Animator, Node>(); anim.mNodes = new ArrayList<Node>(); anim.mSortedNodes = new ArrayList<Node>(); anim.mReversible = mReversible; // Walk through the old nodes list, cloning each node and adding it to the new nodemap. // One problem is that the old node dependencies point to nodes in the old AnimatorSet. Loading Loading @@ -907,6 +913,35 @@ public final class AnimatorSet extends Animator { } } /** * @hide */ @Override public boolean canReverse() { if (!mReversible) { return false; } // Loop to make sure all the Nodes can reverse. for (Node node : mNodes) { if (!node.animation.canReverse() || node.animation.getStartDelay() > 0) { return false; } } return true; } /** * @hide */ @Override public void reverse() { if (canReverse()) { for (Node node : mNodes) { node.animation.reverse(); } } } /** * Dependency holds information about the node that some other node is * dependent upon and the nature of that dependency. Loading Loading @@ -1124,6 +1159,7 @@ public final class AnimatorSet extends Animator { * {@link AnimatorSet#play(Animator)} method ends. */ public Builder before(Animator anim) { mReversible = false; Node node = mNodeMap.get(anim); if (node == null) { node = new Node(anim); Loading @@ -1144,6 +1180,7 @@ public final class AnimatorSet extends Animator { * {@link AnimatorSet#play(Animator)} method to play. */ public Builder after(Animator anim) { mReversible = false; Node node = mNodeMap.get(anim); if (node == null) { node = new Node(anim); Loading core/java/android/animation/ValueAnimator.java +9 −0 Original line number Diff line number Diff line Loading @@ -1038,6 +1038,7 @@ public class ValueAnimator extends Animator { * play backwards. This behavior is only set for the current animation; future playing * of the animation will use the default behavior of playing forward. */ @Override public void reverse() { mPlayingBackwards = !mPlayingBackwards; if (mPlayingState == RUNNING) { Loading @@ -1052,6 +1053,14 @@ public class ValueAnimator extends Animator { } } /** * @hide */ @Override public boolean canReverse() { return true; } /** * Called internally to end an animation by removing it from the animations list. Must be * called on the UI thread. Loading graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +10 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.res.Resources; import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.Log; import android.util.LongSparseLongArray; import android.util.SparseIntArray; import android.util.StateSet; Loading Loading @@ -62,6 +63,8 @@ import java.io.IOException; * @attr ref android.R.styleable#DrawableStates_state_pressed */ public class AnimatedStateListDrawable extends StateListDrawable { private static final String LOGTAG = AnimatedStateListDrawable.class.getSimpleName(); private static final String ELEMENT_TRANSITION = "transition"; private static final String ELEMENT_ITEM = "item"; Loading Loading @@ -302,13 +305,13 @@ public class AnimatedStateListDrawable extends StateListDrawable { @Override public boolean canReverse() { return true; return mAvd.canReverse(); } @Override public void start() { if (mReversed) { mAvd.reverse(); reverse(); } else { mAvd.start(); } Loading @@ -316,7 +319,11 @@ public class AnimatedStateListDrawable extends StateListDrawable { @Override public void reverse() { if (canReverse()) { mAvd.reverse(); } else { Log.w(LOGTAG, "Reverse() is called on a drawable can't reverse"); } } @Override Loading graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +21 −3 Original line number Diff line number Diff line Loading @@ -337,15 +337,33 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { * Reverses ongoing animations or starts pending animations in reverse. * <p> * NOTE: Only works of all animations are ValueAnimators. * @hide */ void reverse() { public void reverse() { final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators; final int size = animators.size(); for (int i = 0; i < size; i++) { final Animator animator = animators.get(i); if (animator instanceof ValueAnimator) { ((ValueAnimator) animator).reverse(); if (animator.canReverse()) { animator.reverse(); } else { Log.w(LOGTAG, "AnimatedVectorDrawable can't reverse()"); } } } /** * @hide */ public boolean canReverse() { final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators; final int size = animators.size(); for (int i = 0; i < size; i++) { final Animator animator = animators.get(i); if (!animator.canReverse()) { return false; } } return true; } } Loading
core/java/android/animation/Animator.java +16 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,22 @@ public abstract class Animator implements Cloneable { public void setTarget(Object target) { } // Hide reverse() and canReverse() for now since reverse() only work for simple // cases, like we don't support sequential, neither startDelay. // TODO: make reverse() works for all the Animators. /** * @hide */ public boolean canReverse() { return false; } /** * @hide */ public void reverse() { } /** * <p>An animation listener receives notifications from an animation. * Notifications indicate animation related events, such as the end or the Loading
core/java/android/animation/AnimatorSet.java +39 −2 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public final class AnimatorSet extends Animator { // was set on this AnimatorSet, so it should not be passed down to the children. private TimeInterpolator mInterpolator = null; private boolean mReversible = true; /** * Sets up this AnimatorSet to play all of the supplied animations at the same time. * This is equivalent to calling {@link #play(Animator)} with the first animator in the Loading Loading @@ -177,6 +177,7 @@ public final class AnimatorSet extends Animator { if (items.length == 1) { play(items[0]); } else { mReversible = false; for (int i = 0; i < items.length - 1; ++i) { play(items[i]).before(items[i+1]); } Loading @@ -196,6 +197,7 @@ public final class AnimatorSet extends Animator { if (items.size() == 1) { play(items.get(0)); } else { mReversible = false; for (int i = 0; i < items.size() - 1; ++i) { play(items.get(i)).before(items.get(i+1)); } Loading Loading @@ -407,6 +409,9 @@ public final class AnimatorSet extends Animator { */ @Override public void setStartDelay(long startDelay) { if (mStartDelay > 0) { mReversible = false; } mStartDelay = startDelay; } Loading Loading @@ -626,6 +631,7 @@ public final class AnimatorSet extends Animator { anim.mNodeMap = new HashMap<Animator, Node>(); anim.mNodes = new ArrayList<Node>(); anim.mSortedNodes = new ArrayList<Node>(); anim.mReversible = mReversible; // Walk through the old nodes list, cloning each node and adding it to the new nodemap. // One problem is that the old node dependencies point to nodes in the old AnimatorSet. Loading Loading @@ -907,6 +913,35 @@ public final class AnimatorSet extends Animator { } } /** * @hide */ @Override public boolean canReverse() { if (!mReversible) { return false; } // Loop to make sure all the Nodes can reverse. for (Node node : mNodes) { if (!node.animation.canReverse() || node.animation.getStartDelay() > 0) { return false; } } return true; } /** * @hide */ @Override public void reverse() { if (canReverse()) { for (Node node : mNodes) { node.animation.reverse(); } } } /** * Dependency holds information about the node that some other node is * dependent upon and the nature of that dependency. Loading Loading @@ -1124,6 +1159,7 @@ public final class AnimatorSet extends Animator { * {@link AnimatorSet#play(Animator)} method ends. */ public Builder before(Animator anim) { mReversible = false; Node node = mNodeMap.get(anim); if (node == null) { node = new Node(anim); Loading @@ -1144,6 +1180,7 @@ public final class AnimatorSet extends Animator { * {@link AnimatorSet#play(Animator)} method to play. */ public Builder after(Animator anim) { mReversible = false; Node node = mNodeMap.get(anim); if (node == null) { node = new Node(anim); Loading
core/java/android/animation/ValueAnimator.java +9 −0 Original line number Diff line number Diff line Loading @@ -1038,6 +1038,7 @@ public class ValueAnimator extends Animator { * play backwards. This behavior is only set for the current animation; future playing * of the animation will use the default behavior of playing forward. */ @Override public void reverse() { mPlayingBackwards = !mPlayingBackwards; if (mPlayingState == RUNNING) { Loading @@ -1052,6 +1053,14 @@ public class ValueAnimator extends Animator { } } /** * @hide */ @Override public boolean canReverse() { return true; } /** * Called internally to end an animation by removing it from the animations list. Must be * called on the UI thread. Loading
graphics/java/android/graphics/drawable/AnimatedStateListDrawable.java +10 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.res.Resources; import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.util.AttributeSet; import android.util.Log; import android.util.LongSparseLongArray; import android.util.SparseIntArray; import android.util.StateSet; Loading Loading @@ -62,6 +63,8 @@ import java.io.IOException; * @attr ref android.R.styleable#DrawableStates_state_pressed */ public class AnimatedStateListDrawable extends StateListDrawable { private static final String LOGTAG = AnimatedStateListDrawable.class.getSimpleName(); private static final String ELEMENT_TRANSITION = "transition"; private static final String ELEMENT_ITEM = "item"; Loading Loading @@ -302,13 +305,13 @@ public class AnimatedStateListDrawable extends StateListDrawable { @Override public boolean canReverse() { return true; return mAvd.canReverse(); } @Override public void start() { if (mReversed) { mAvd.reverse(); reverse(); } else { mAvd.start(); } Loading @@ -316,7 +319,11 @@ public class AnimatedStateListDrawable extends StateListDrawable { @Override public void reverse() { if (canReverse()) { mAvd.reverse(); } else { Log.w(LOGTAG, "Reverse() is called on a drawable can't reverse"); } } @Override Loading
graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +21 −3 Original line number Diff line number Diff line Loading @@ -337,15 +337,33 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { * Reverses ongoing animations or starts pending animations in reverse. * <p> * NOTE: Only works of all animations are ValueAnimators. * @hide */ void reverse() { public void reverse() { final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators; final int size = animators.size(); for (int i = 0; i < size; i++) { final Animator animator = animators.get(i); if (animator instanceof ValueAnimator) { ((ValueAnimator) animator).reverse(); if (animator.canReverse()) { animator.reverse(); } else { Log.w(LOGTAG, "AnimatedVectorDrawable can't reverse()"); } } } /** * @hide */ public boolean canReverse() { final ArrayList<Animator> animators = mAnimatedVectorState.mAnimators; final int size = animators.size(); for (int i = 0; i < size; i++) { final Animator animator = animators.get(i); if (!animator.canReverse()) { return false; } } return true; } }