diff options
author | Michael Jurka <mikejurka@google.com> | 2013-04-22 15:11:58 +0200 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2013-04-22 15:11:58 +0200 |
commit | 98a7174d0ae87e2dbc184cc9cfb2670075bb8611 (patch) | |
tree | 15f65aec67abd58e9cc499429f6e203dd55c770c /packages/SystemUI/src/com/android/systemui/recent | |
parent | 323efd55d3e5cd14441e393f6c4b00280e60127b (diff) | |
download | frameworks_base-98a7174d0ae87e2dbc184cc9cfb2670075bb8611.zip frameworks_base-98a7174d0ae87e2dbc184cc9cfb2670075bb8611.tar.gz frameworks_base-98a7174d0ae87e2dbc184cc9cfb2670075bb8611.tar.bz2 |
Update animation helper class to most recent version
Most updated version is currently in Launcher2
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/recent')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/recent/FirstFrameAnimatorHelper.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recent/FirstFrameAnimatorHelper.java b/packages/SystemUI/src/com/android/systemui/recent/FirstFrameAnimatorHelper.java index 2fc7dfc..84d13cf 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/FirstFrameAnimatorHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recent/FirstFrameAnimatorHelper.java @@ -19,18 +19,18 @@ package com.android.systemui.recent; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; -import android.animation.Animator.AnimatorListener; import android.util.Log; -import android.view.ViewTreeObserver; import android.view.View; import android.view.ViewPropertyAnimator; +import android.view.ViewTreeObserver; /* * This is a helper class that listens to updates from the corresponding animation. * For the first two frames, it adjusts the current play time of the animation to * prevent jank at the beginning of the animation */ -public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateListener { +public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter + implements ValueAnimator.AnimatorUpdateListener { private static final boolean DEBUG = false; private static final int MAX_DELAY = 1000; private static final int IDEAL_FRAME_DURATION = 16; @@ -50,13 +50,14 @@ public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateLis public FirstFrameAnimatorHelper(ViewPropertyAnimator vpa, View target) { mTarget = target; - vpa.setListener(new AnimatorListenerAdapter() { - public void onAnimationStart (Animator animation) { - final ValueAnimator va = (ValueAnimator) animation; - va.addUpdateListener(FirstFrameAnimatorHelper.this); - onAnimationUpdate(va); - } - }); + vpa.setListener(this); + } + + // only used for ViewPropertyAnimators + public void onAnimationStart(Animator animation) { + final ValueAnimator va = (ValueAnimator) animation; + va.addUpdateListener(FirstFrameAnimatorHelper.this); + onAnimationUpdate(va); } public static void initializeDrawListener(View view) { @@ -84,7 +85,11 @@ public class FirstFrameAnimatorHelper implements ValueAnimator.AnimatorUpdateLis mStartTime = currentTime; } - if (!mHandlingOnAnimationUpdate) { + if (!mHandlingOnAnimationUpdate && + // If the current play time exceeds the duration, the animation + // will get finished, even if we call setCurrentPlayTime -- therefore + // don't adjust the animation in that case + animation.getCurrentPlayTime() < animation.getDuration()) { mHandlingOnAnimationUpdate = true; long frameNum = sGlobalFrameCounter - mStartFrame; // If we haven't drawn our first frame, reset the time to t = 0 |