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

Commit c299a338 authored by Chet Haase's avatar Chet Haase
Browse files

Fix AnimatorSet duration issue

Setting the duration on an AnimatorSet should propagate that value
to its children. This works, but only if all children are added to the set
before setDuration() is called. This fix delays that propagation until
the set is started, making it possible to have a more flexible order of when
the children are added and when the duration is set.

Issue #6324904 AnimatorSet durations too long

Change-Id: I797971c2310eb2e3fe931b4aa35de505f2a519f7
parent 0a1c6c8b
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -420,11 +420,7 @@ public final class AnimatorSet extends Animator {
        if (duration < 0) {
        if (duration < 0) {
            throw new IllegalArgumentException("duration must be a value of zero or greater");
            throw new IllegalArgumentException("duration must be a value of zero or greater");
        }
        }
        for (Node node : mNodes) {
        // Just record the value for now - it will be used later when the AnimatorSet starts
            // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to
            // insert "play-after" delays
            node.animation.setDuration(duration);
        }
        mDuration = duration;
        mDuration = duration;
        return this;
        return this;
    }
    }
@@ -456,6 +452,14 @@ public final class AnimatorSet extends Animator {
        mTerminated = false;
        mTerminated = false;
        mStarted = true;
        mStarted = true;


        if (mDuration >= 0) {
            // If the duration was set on this AnimatorSet, pass it along to all child animations
            for (Node node : mNodes) {
                // TODO: don't set the duration of the timing-only nodes created by AnimatorSet to
                // insert "play-after" delays
                node.animation.setDuration(mDuration);
            }
        }
        // First, sort the nodes (if necessary). This will ensure that sortedNodes
        // First, sort the nodes (if necessary). This will ensure that sortedNodes
        // contains the animation nodes in the correct order.
        // contains the animation nodes in the correct order.
        sortNodes();
        sortNodes();