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

Commit a28f0003 authored by Doris Liu's avatar Doris Liu Committed by android-build-merger
Browse files

Merge \"Fix setCurrentPlayTime for started but not yet pulsed animations\" into nyc-dev

am: 42d39300

Change-Id: I7c1f2adb31ece266b082ffb9ea85b17c083b518c
parents fead52eb 42d39300
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -602,7 +602,9 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
        long currentTime = AnimationUtils.currentAnimationTimeMillis();
        mStartTime = currentTime - seekTime;
        mStartTimeCommitted = true; // do not allow start time to be compensated for jank
        if (!mRunning) {
        if (!isPulsingInternal()) {
            // If the animation loop hasn't started, the startTime will be adjusted in the first
            // frame based on seek fraction.
            mSeekFraction = fraction;
        }
        mOverallFraction = fraction;
@@ -980,6 +982,10 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
        mStarted = true;
        mPaused = false;
        mRunning = false;
        // Resets mLastFrameTime when start() is called, so that if the animation was running,
        // calling start() would put the animation in the
        // started-but-not-yet-reached-the-first-frame phase.
        mLastFrameTime = 0;
        AnimationHandler animationHandler = AnimationHandler.getInstance();
        animationHandler.addAnimationFrameCallback(this, (long) (mStartDelay * sDurationScale));

@@ -1095,7 +1101,7 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
     */
    @Override
    public void reverse() {
        if (mRunning) {
        if (isPulsingInternal()) {
            long currentTime = AnimationUtils.currentAnimationTimeMillis();
            long currentPlayTime = currentTime - mStartTime;
            long timeLeft = getScaledDuration() - currentPlayTime;
@@ -1103,6 +1109,7 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
            mStartTimeCommitted = true; // do not allow start time to be compensated for jank
            mReversing = !mReversing;
        } else if (mStarted) {
            mReversing = !mReversing;
            end();
        } else {
            start(true);
@@ -1176,6 +1183,15 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio
        }
    }

    /**
     * Internal only: This tracks whether the animation has gotten on the animation loop. Note
     * this is different than {@link #isRunning()} in that the latter tracks the time after start()
     * is called (or after start delay if any), which may be before the animation loop starts.
     */
    private boolean isPulsingInternal() {
        return mLastFrameTime > 0;
    }

    /**
     * Returns the name of this animator for debugging purposes.
     */