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

Commit 6ba5ed32 authored by Doris Liu's avatar Doris Liu
Browse files

Use listener to determine whether an Animator has ended

BUG: 34736819
Test: ran cts test for ValueAnimator and AnimatorSet
Change-Id: Ia1070f83833940cb09d26243f5873751d9ca2a38
parent 11c80cf3
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -469,8 +469,9 @@ public abstract class Animator implements Cloneable, AnimationHandler.AnimationF
     */
    @Override
    public boolean doAnimationFrame(long frameTime) {
        // TODO: Need to find a better signal than this
        return getDuration() + getStartDelay() >= frameTime;
        // TODO: Need to find a better signal than this. There's a bug in SystemUI that's preventing
        // returning !isStarted() from working.
        return false;
    }

    /**
+22 −2
Original line number Diff line number Diff line
@@ -174,9 +174,18 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
     */
    private long mPauseTime = -1;

    // This is to work around a bug in b/34736819. This needs to be removed once play team
    // This is to work around a bug in b/34736819. This needs to be removed once app team
    // fixes their side.
    private AnimatorListenerAdapter mDummyListener = new AnimatorListenerAdapter() {};
    private AnimatorListenerAdapter mDummyListener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mNodeMap.get(animation) == null) {
                throw new AndroidRuntimeException("Error: animation ended is not in the node map");
            }
            mNodeMap.get(animation).mEnded = true;

        }
    };

    public AnimatorSet() {
        super();
@@ -1172,6 +1181,17 @@ public final class AnimatorSet extends Animator implements AnimationHandler.Anim
        anim.mNodeMap = new ArrayMap<Animator, Node>();
        anim.mNodes = new ArrayList<Node>(nodeCount);
        anim.mEvents = new ArrayList<AnimationEvent>();
        anim.mDummyListener = new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (anim.mNodeMap.get(animation) == null) {
                    throw new AndroidRuntimeException("Error: animation ended is not in the node"
                            + " map");
                }
                anim.mNodeMap.get(animation).mEnded = true;

            }
        };
        anim.mReversing = false;
        anim.mDependencyDirty = true;