OSDN Git Service

Zero duration animations snap to end value when started
authorChet Haase <chet@google.com>
Mon, 1 Dec 2014 14:57:15 +0000 (06:57 -0800)
committerChet Haase <chet@google.com>
Mon, 1 Dec 2014 14:57:15 +0000 (06:57 -0800)
A recent change to seeking behavior altered the logic of
setCurrentPlayTime() (which is called when animations are first
started) to set the current animated fraction to 0 for 0-duration
animations. This fix ensures that 0-duration animations snap to
their end value (fraction == 1) instead, matching the behavior
prior to the seeking fix.

Issue #18542543 Animations with 0 duration stay in initial state when calling setCurrentPlayTime(0)

Change-Id: I9916d962cf46453a9e3e1207f58baf16f4a5830a

core/java/android/animation/ValueAnimator.java

index d65b490..e18aa5c 100644 (file)
@@ -537,8 +537,7 @@ public class ValueAnimator extends Animator {
      * @param playTime The time, in milliseconds, to which the animation is advanced or rewound.
      */
     public void setCurrentPlayTime(long playTime) {
-        float fraction = mUnscaledDuration > 0 ? (float) playTime / mUnscaledDuration :
-                playTime == 0 ? 0 : 1;
+        float fraction = mUnscaledDuration > 0 ? (float) playTime / mUnscaledDuration : 1;
         setCurrentFraction(fraction);
     }