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

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

Make sure the correct AnimatorListeners gets called

This CL fixes the bug where when there're AnimatorSet inside of
AnimatorSet, incorrect AnimatorListeners get notified of the
Animator's lifecycle events.

Bug: 22940651
Bug: 22954352
Change-Id: I2bf66413d54dcfc75dc7fa779e723443763a30a5
parent 1c37aa88
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -702,7 +702,7 @@ public final class AnimatorSet extends Animator {
    }


    private class AnimatorSetListener implements AnimatorListener {
    private static class AnimatorSetListener implements AnimatorListener {

        private AnimatorSet mAnimatorSet;

@@ -712,7 +712,7 @@ public final class AnimatorSet extends Animator {

        public void onAnimationCancel(Animator animation) {

            if (!mTerminated) {
            if (!mAnimatorSet.mTerminated) {
                // Listeners are already notified of the AnimatorSet canceling in cancel().
                // The logic below only kicks in when animations end normally
                if (mAnimatorSet.mPlayingSet.size() == 0) {
@@ -734,7 +734,7 @@ public final class AnimatorSet extends Animator {
            Node animNode = mAnimatorSet.mNodeMap.get(animation);
            animNode.mEnded = true;

            if (!mTerminated) {
            if (!mAnimatorSet.mTerminated) {
                List<Node> children = animNode.mChildNodes;
                // Start children animations, if any.
                int childrenSize = children == null ? 0 : children.size();
@@ -747,9 +747,9 @@ public final class AnimatorSet extends Animator {
                // end(); the logic below only kicks in when animations end normally
                boolean allDone = true;
                // Traverse the tree and find if there's any unfinished node
                int size = mNodes.size();
                int size = mAnimatorSet.mNodes.size();
                for (int i = 0; i < size; i++) {
                    if (!mNodes.get(i).mEnded) {
                    if (!mAnimatorSet.mNodes.get(i).mEnded) {
                        allDone = false;
                        break;
                    }
@@ -757,9 +757,9 @@ public final class AnimatorSet extends Animator {
                if (allDone) {
                    // If this was the last child animation to end, then notify listeners that this
                    // AnimatorSet has ended
                    if (mListeners != null) {
                    if (mAnimatorSet.mListeners != null) {
                        ArrayList<AnimatorListener> tmpListeners =
                                (ArrayList<AnimatorListener>) mListeners.clone();
                                (ArrayList<AnimatorListener>) mAnimatorSet.mListeners.clone();
                        int numListeners = tmpListeners.size();
                        for (int i = 0; i < numListeners; ++i) {
                            tmpListeners.get(i).onAnimationEnd(mAnimatorSet);