From 7a08fe0e09c9bd5b66049738617cc9972651bf5b Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 7 Oct 2014 15:55:35 -0700 Subject: Reapply animation duration scale each time it is started. When Battery Saver mode is enabled, we set the animation duration scale factor to 0 to effectively disable all animations. Later when it is disabled, we reset the animation duration scale factor to 1. This change ensures that we reapply the duration scale factor whenever the animation is started instead of only applying it once when the duration is set (usually when the animation is created). This ensures that the correct scale factor is applied even when it changes after the animation has been initialized. Previously, certain animations would continue to be suppressed even after Battery Saver mode was disengaged. This wasn't much of an issue when the duration scale was initially implemented as a developer setting but now that it is exposed via Battery Saver the artifacts caused by this bug have become visible to users. Bug: 17887431 Change-Id: I91ba5ca0505d02ac389a31d067e38886112fa0c8 --- core/java/android/animation/ValueAnimator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/java') diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index 9435dfb..0d17d67 100644 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -508,10 +508,14 @@ public class ValueAnimator extends Animator { duration); } mUnscaledDuration = duration; - mDuration = (long)(duration * sDurationScale); + updateScaledDuration(); return this; } + private void updateScaledDuration() { + mDuration = (long)(mUnscaledDuration * sDurationScale); + } + /** * Gets the length of the animation. The default duration is 300 milliseconds. * @@ -947,6 +951,7 @@ public class ValueAnimator extends Animator { mStarted = true; mStartedDelay = false; mPaused = false; + updateScaledDuration(); // in case the scale factor has changed since creation time AnimationHandler animationHandler = getOrCreateAnimationHandler(); animationHandler.mPendingAnimations.add(this); if (mStartDelay == 0) { -- cgit v1.1