Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4365e5a1 authored by Chet Haase's avatar Chet Haase
Browse files

Fix ValueAnimator.getCurrentPlayTime()

Return a valid value for the current play time if the animator has
been seeked to a play time or fraction, but not yet started.

Issue #24717972 animator.getCurrentPlayTime() is all messed up

Change-Id: I15f1329b65410b4b0366a23a3419b5987305a865
parent 4164e6a8
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -625,14 +625,19 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
    /**
     * Gets the current position of the animation in time, which is equal to the current
     * time minus the time that the animation started. An animation that is not yet started will
     * return a value of zero.
     * return a value of zero, unless the animation has has its play time set via
     * {@link #setCurrentPlayTime(long)} or {@link #setCurrentFraction(float)}, in which case
     * it will return the time that was set.
     *
     * @return The current position in time of the animation.
     */
    public long getCurrentPlayTime() {
        if (!mInitialized || !mStarted) {
        if (!mInitialized || (!mStarted && mSeekFraction < 0)) {
            return 0;
        }
        if (mSeekFraction >= 0) {
            return (long) (mUnscaledDuration * mSeekFraction);
        }
        return AnimationUtils.currentAnimationTimeMillis() - mStartTime;
    }