[automerger] Fixing stateManager not correctly deduping existing animations am: a6616dec28

Change-Id: Ie76b586874121a8e0fb539b373cfc7c2c1e9032c
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 7f25301..1b9ac21 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -374,7 +374,18 @@
      */
     public void setCurrentAnimation(AnimatorSet anim, Animator... childAnimations) {
         for (Animator childAnim : childAnimations) {
-            if (childAnim != null && mConfig.mCurrentAnimation == childAnim) {
+            if (childAnim == null) {
+                continue;
+            }
+            if (mConfig.playbackController != null
+                    && mConfig.playbackController.getTarget() == childAnim) {
+                if (mConfig.mCurrentAnimation != null) {
+                    mConfig.mCurrentAnimation.removeListener(mConfig);
+                    mConfig.mCurrentAnimation = null;
+                }
+                mConfig.playbackController = null;
+                break;
+            } else if (mConfig.mCurrentAnimation == childAnim) {
                 mConfig.mCurrentAnimation.removeListener(mConfig);
                 mConfig.mCurrentAnimation = null;
                 break;