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

Commit 6a7256fc authored by Doris Liu's avatar Doris Liu Committed by Android (Google) Code Review
Browse files

Merge "Fix 0 duration scale for pre-O apps"

parents ea0a092d d7968dc1
Loading
Loading
Loading
Loading
+23 −24
Original line number Diff line number Diff line
@@ -431,32 +431,29 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim

    // Force all the animations to end when the duration scale is 0.
    private void forceToEnd() {
        if (mEndCanBeCalled) {
            end();
        } else {
        // TODO: Below is commented out to temp work around b/36241584, uncomment this when it's
        // fixed.
//        if (mEndCanBeCalled) {
//            end();
//            return;
//        }

        // Note: we don't want to combine this case with the end() method below because in
        // the case of developer calling end(), we still need to make sure end() is explicitly
        // called on the child animators to maintain the old behavior.
        if (mReversing) {
                mLastEventId = mLastEventId == -1 ? mEvents.size() : mLastEventId;
                for (int j = mLastEventId - 1; j >= 0; j--) {
                    AnimationEvent event = mEvents.get(j);
                    if (event.mEvent == AnimationEvent.ANIMATION_END) {
                        event.mNode.mAnimation.reverse();
                    }
                }
            handleAnimationEvents(mLastEventId, 0, getTotalDuration());
        } else {
                for (int j = mLastEventId + 1; j < mEvents.size(); j++) {
                    AnimationEvent event = mEvents.get(j);
                    if (event.mEvent == AnimationEvent.ANIMATION_START) {
                        event.mNode.mAnimation.start();
                    }
            long zeroScalePlayTime = getTotalDuration();
            if (zeroScalePlayTime == DURATION_INFINITE) {
                // Use a large number for the play time.
                zeroScalePlayTime = Integer.MAX_VALUE;
            }
            handleAnimationEvents(mLastEventId, mEvents.size() - 1, zeroScalePlayTime);
        }
        mPlayingSet.clear();
        endAnimation();
    }
    }

    /**
     * {@inheritDoc}
@@ -730,7 +727,7 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
        if (isEmptySet) {
            // In the case of empty AnimatorSet, or 0 duration scale, we will trigger the
            // onAnimationEnd() right away.
            forceToEnd();
            end();
        }
    }

@@ -1130,8 +1127,10 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
     */
    private void pulseFrame(Node node, long animPlayTime) {
        if (!node.mEnded) {
            float durationScale = ValueAnimator.getDurationScale();
            durationScale = durationScale == 0  ? 1 : durationScale;
            node.mEnded = node.mAnimation.pulseAnimationFrame(
                    (long) (animPlayTime * ValueAnimator.getDurationScale()));
                    (long) (animPlayTime * durationScale));
        }
    }