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

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

Merge "Fix out of order listener callback for animator set containing empty sets"

parents e637f315 f66d2f6f
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -635,12 +635,12 @@ public final class AnimatorSet extends Animator {
        boolean setIsEmpty = false;
        if (mStartDelay > 0) {
            start(mRootNode);
        } else if (mNodes.size() > 1) {
        } else if (isEmptySet(this)) {
            // Set is empty or contains only empty animator sets. Skip to end in this case.
            setIsEmpty = true;
        } else {
            // No delay, but there are other animators in the set
            onChildAnimatorEnded(mDelayAnim);
        } else {
            // Set is empty, no delay, no other animation. Skip to end in this case
            setIsEmpty = true;
        }

        if (mListeners != null) {
@@ -657,6 +657,25 @@ public final class AnimatorSet extends Animator {
        }
    }

    // Returns true if set is empty or contains nothing but animator sets with no start delay.
    private static boolean isEmptySet(AnimatorSet set) {
        if (set.getStartDelay() > 0) {
            return false;
        }
        for (int i = 0; i < set.getChildAnimations().size(); i++) {
            Animator anim = set.getChildAnimations().get(i);
            if (!(anim instanceof AnimatorSet)) {
                // Contains non-AnimatorSet, not empty.
                return false;
            } else {
                if (!isEmptySet((AnimatorSet) anim)) {
                    return false;
                }
            }
        }
        return true;
    }

    private void updateAnimatorsDuration() {
        if (mDuration >= 0) {
            // If the duration was set on this AnimatorSet, pass it along to all child animations