Only skip the animation, if we are going to the same state

Bug: 77487950
Change-Id: I2d3e376094b0fb0d3120ab6c4d6569f52ab8273f
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 01166a1..e611af7 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -173,7 +173,7 @@
                     onCompleteRunnable.run();
                 }
                 return;
-            } else if (!mConfig.userControlled && animated) {
+            } else if (!mConfig.userControlled && animated && mConfig.mTargetState == state) {
                 // We are running the same animation as requested
                 if (onCompleteRunnable != null) {
                     mConfig.mCurrentAnimation.addListener(new AnimationSuccessListener() {
@@ -280,7 +280,7 @@
                 onStateTransitionEnd(state);
             }
         });
-        mConfig.setAnimation(animation);
+        mConfig.setAnimation(animation, state);
         return mConfig.mCurrentAnimation;
     }
 
@@ -370,7 +370,7 @@
         if (reapplyNeeded) {
             reapplyState();
         }
-        mConfig.setAnimation(anim);
+        mConfig.setAnimation(anim, null);
     }
 
     private class StartAnimRunnable implements Runnable {
@@ -401,11 +401,13 @@
         private PropertySetter mProperSetter;
 
         private AnimatorSet mCurrentAnimation;
+        private LauncherState mTargetState;
 
         public void reset() {
             duration = 0;
             userControlled = false;
             mProperSetter = null;
+            mTargetState = null;
 
             if (mCurrentAnimation != null) {
                 mCurrentAnimation.setDuration(0);
@@ -429,8 +431,9 @@
             }
         }
 
-        public void setAnimation(AnimatorSet animation) {
+        public void setAnimation(AnimatorSet animation, LauncherState targetState) {
             mCurrentAnimation = animation;
+            mTargetState = targetState;
             mCurrentAnimation.addListener(this);
         }
     }