diff options
author | Patrick Dubroy <dubroy@google.com> | 2010-10-14 23:54:22 -0700 |
---|---|---|
committer | Patrick Dubroy <dubroy@google.com> | 2010-10-15 14:12:36 -0700 |
commit | 08ae2ec4847a971ad1b19c163e3a0d6307a8ed72 (patch) | |
tree | b3404119ec2cfd0fee434afb862162e59848afa7 /src/com/android/launcher2/InterruptibleInOutAnimator.java | |
parent | 45fd79ea8d71ef03a138fadaaaf3c761f9f51cca (diff) | |
download | android_packages_apps_Trebuchet-08ae2ec4847a971ad1b19c163e3a0d6307a8ed72.tar.gz android_packages_apps_Trebuchet-08ae2ec4847a971ad1b19c163e3a0d6307a8ed72.tar.bz2 android_packages_apps_Trebuchet-08ae2ec4847a971ad1b19c163e3a0d6307a8ed72.zip |
Fix bug drag viz & hover state
Change-Id: I6b40d4dd43a2ee0c127df938375870347faeb5f6
Diffstat (limited to 'src/com/android/launcher2/InterruptibleInOutAnimator.java')
-rw-r--r-- | src/com/android/launcher2/InterruptibleInOutAnimator.java | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/com/android/launcher2/InterruptibleInOutAnimator.java b/src/com/android/launcher2/InterruptibleInOutAnimator.java index bed7e6b28..5ebe60507 100644 --- a/src/com/android/launcher2/InterruptibleInOutAnimator.java +++ b/src/com/android/launcher2/InterruptibleInOutAnimator.java @@ -43,7 +43,7 @@ public class InterruptibleInOutAnimator { private static final int IN = 1; private static final int OUT = 2; - + // TODO: This isn't really necessary, but is here to help diagnose a bug in the drag viz private int mDirection = STOPPED; public InterruptibleInOutAnimator(long duration, float fromValue, float toValue) { @@ -51,6 +51,12 @@ public class InterruptibleInOutAnimator { mOriginalDuration = duration; mOriginalFromValue = fromValue; mOriginalToValue = toValue; + + mAnimator.addListener(new AnimatorListenerAdapter() { + public void onAnimationEnd(Animator animation) { + mDirection = STOPPED; + } + }); } private void animate(int direction) { @@ -62,13 +68,17 @@ public class InterruptibleInOutAnimator { // Make sure it's stopped before we modify any values cancel(); - if (startValue != toValue) { - mDirection = direction; - mAnimator.setDuration(mOriginalDuration - currentPlayTime); - mAnimator.setFloatValues(startValue, toValue); - mAnimator.start(); - mFirstRun = false; - } + // TODO: We don't really need to do the animation if startValue == toValue, but + // somehow that doesn't seem to work, possibly a quirk of the animation framework + mDirection = direction; + + // Ensure we don't calculate a non-sensical duration + long duration = mOriginalDuration - currentPlayTime; + mAnimator.setDuration(Math.max(0, Math.min(duration, mOriginalDuration))); + + mAnimator.setFloatValues(startValue, toValue); + mAnimator.start(); + mFirstRun = false; } public void cancel() { |