summaryrefslogtreecommitdiffstats
path: root/core/java/android/animation
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-02-15 15:06:01 -0800
committerJeff Brown <jeffbrown@google.com>2012-02-15 15:06:01 -0800
commit4a06c8008b2edd6677f9a411af79b0a4971b87fe (patch)
treece3bca001e3f2a7778d39be2cb5049f7b1620e16 /core/java/android/animation
parentfef3d62b16bccd9ef7a32c2e1da94f694b34c405 (diff)
downloadframeworks_base-4a06c8008b2edd6677f9a411af79b0a4971b87fe.zip
frameworks_base-4a06c8008b2edd6677f9a411af79b0a4971b87fe.tar.gz
frameworks_base-4a06c8008b2edd6677f9a411af79b0a4971b87fe.tar.bz2
Simplify Choreographer API.
Removed the listeners and schedule animation / draw methods. Instead all requests are posted as one-shot callbacks, which is a better match for how clients actually use the Choreographer. Bug: 5721047 Change-Id: I113180b2713a300e4444d0d987f52b8157b7ac15
Diffstat (limited to 'core/java/android/animation')
-rwxr-xr-xcore/java/android/animation/ValueAnimator.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index cc1efb9..6fbeee3 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -522,8 +522,7 @@ public class ValueAnimator extends Animator {
* animations possible.
*
*/
- private static class AnimationHandler extends Handler
- implements Choreographer.OnAnimateListener {
+ private static class AnimationHandler extends Handler implements Runnable {
// The per-thread list of all active animations
private final ArrayList<ValueAnimator> mAnimations = new ArrayList<ValueAnimator>();
@@ -539,7 +538,7 @@ public class ValueAnimator extends Animator {
private final ArrayList<ValueAnimator> mReadyAnims = new ArrayList<ValueAnimator>();
private final Choreographer mChoreographer;
- private boolean mIsChoreographed;
+ private boolean mAnimationScheduled;
private AnimationHandler() {
mChoreographer = Choreographer.getInstance();
@@ -644,22 +643,17 @@ public class ValueAnimator extends Animator {
// If there are still active or delayed animations, schedule a future call to
// onAnimate to process the next frame of the animations.
- if (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty()) {
- if (!mIsChoreographed) {
- mIsChoreographed = true;
- mChoreographer.addOnAnimateListener(this);
- }
- mChoreographer.scheduleAnimation();
- } else {
- if (mIsChoreographed) {
- mIsChoreographed = false;
- mChoreographer.removeOnAnimateListener(this);
- }
+ if (!mAnimationScheduled
+ && (!mAnimations.isEmpty() || !mDelayedAnims.isEmpty())) {
+ mChoreographer.postAnimationCallback(this);
+ mAnimationScheduled = true;
}
}
+ // Called by the Choreographer.
@Override
- public void onAnimate() {
+ public void run() {
+ mAnimationScheduled = false;
doAnimationFrame();
}
}