From c01bd1167a1b08d59557f214ddc48cf24d3b8d0a Mon Sep 17 00:00:00 2001 From: John Reck Date: Fri, 18 Jul 2014 16:22:09 -0700 Subject: Return Animator instead of ValueAnimator Change-Id: I29a7cfdc7ffbb3a4d33f9e64f9d7ca791f5c947c --- core/java/android/animation/Animator.java | 35 +++++++++++++++++++++++++ core/java/android/animation/RevealAnimator.java | 31 +--------------------- core/java/android/animation/ValueAnimator.java | 1 + 3 files changed, 37 insertions(+), 30 deletions(-) (limited to 'core/java/android/animation') diff --git a/core/java/android/animation/Animator.java b/core/java/android/animation/Animator.java index 95f83ac..5f80ed7 100644 --- a/core/java/android/animation/Animator.java +++ b/core/java/android/animation/Animator.java @@ -433,4 +433,39 @@ public abstract class Animator implements Cloneable { */ void onAnimationResume(Animator animation); } + + /** + *

Whether or not the Animator is allowed to run asynchronously off of + * the UI thread. This is a hint that informs the Animator that it is + * OK to run the animation off-thread, however the Animator may decide + * that it must run the animation on the UI thread anyway. + * + *

Regardless of whether or not the animation runs asynchronously, all + * listener callbacks will be called on the UI thread.

+ * + *

To be able to use this hint the following must be true:

+ *
    + *
  1. The animator is immutable while {@link #isStarted()} is true. Requests + * to change duration, delay, etc... may be ignored.
  2. + *
  3. Lifecycle callback events may be asynchronous. Events such as + * {@link Animator.AnimatorListener#onAnimationEnd(Animator)} or + * {@link Animator.AnimatorListener#onAnimationRepeat(Animator)} may end up delayed + * as they must be posted back to the UI thread, and any actions performed + * by those callbacks (such as starting new animations) will not happen + * in the same frame.
  4. + *
  5. State change requests ({@link #cancel()}, {@link #end()}, {@link #reverse()}, etc...) + * may be asynchronous. It is guaranteed that all state changes that are + * performed on the UI thread in the same frame will be applied as a single + * atomic update, however that frame may be the current frame, + * the next frame, or some future frame. This will also impact the observed + * state of the Animator. For example, {@link #isStarted()} may still return true + * after a call to {@link #end()}. Using the lifecycle callbacks is preferred over + * queries to {@link #isStarted()}, {@link #isRunning()}, and {@link #isPaused()} + * for this reason.
  6. + *
+ * @hide + */ + public void setAllowRunningAsynchronously(boolean mayRunAsync) { + // It is up to subclasses to support this, if they can. + } } diff --git a/core/java/android/animation/RevealAnimator.java b/core/java/android/animation/RevealAnimator.java index a1cbd45..53d92e6 100644 --- a/core/java/android/animation/RevealAnimator.java +++ b/core/java/android/animation/RevealAnimator.java @@ -167,38 +167,9 @@ public class RevealAnimator extends ValueAnimator { } @Override - public ValueAnimator clone() { + public RevealAnimator clone() { RevealAnimator anim = (RevealAnimator) super.clone(); anim.mRtAnimator = null; return anim; } - - // ---------------------------------------- - // All the things we don't allow - // ---------------------------------------- - - @Override - public void setValues(PropertyValuesHolder... values) { - throw new IllegalStateException("Cannot change the values of RevealAnimator"); - } - - @Override - public void setFloatValues(float... values) { - throw new IllegalStateException("Cannot change the values of RevealAnimator"); - } - - @Override - public void setIntValues(int... values) { - throw new IllegalStateException("Cannot change the values of RevealAnimator"); - } - - @Override - public void setObjectValues(Object... values) { - throw new IllegalStateException("Cannot change the values of RevealAnimator"); - } - - @Override - public void setEvaluator(TypeEvaluator value) { - throw new IllegalStateException("Cannot change the evaluator of RevealAnimator"); - } } diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index b13838a..9435dfb 100644 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -1409,6 +1409,7 @@ public class ValueAnimator extends Animator { * * @hide */ + @Override public void setAllowRunningAsynchronously(boolean mayRunAsync) { // It is up to subclasses to support this, if they can. } -- cgit v1.1