Using SpringAnimationBuilder instead of SpringObjectAnimator in StaggeredWorkspaceAnim

Change-Id: I3a7b38e3f866c95a92fbb314f0a79b0735f38c9d
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
index 1aa5365..d644fd6 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/StaggeredWorkspaceAnim.java
@@ -21,15 +21,14 @@
 import static com.android.launcher3.anim.Interpolators.LINEAR;
 
 import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
 import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.view.View;
 import android.view.ViewGroup;
 
 import androidx.annotation.Nullable;
 
-import com.android.launcher3.BubbleTextView;
 import com.android.launcher3.CellLayout;
 import com.android.launcher3.DeviceProfile;
 import com.android.launcher3.Launcher;
@@ -40,14 +39,10 @@
 import com.android.launcher3.Workspace;
 import com.android.launcher3.anim.AnimatorSetBuilder;
 import com.android.launcher3.anim.PropertySetter;
-import com.android.launcher3.anim.SpringObjectAnimator;
-import com.android.launcher3.folder.FolderIcon;
+import com.android.launcher3.anim.SpringAnimationBuilder;
 import com.android.launcher3.graphics.OverviewScrim;
 import com.android.launcher3.views.IconLabelDotView;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * Creates an animation where all the workspace items are moved into their final location,
  * staggered row by row from the bottom up.
@@ -69,7 +64,7 @@
     // The original view of the {@link FloatingIconView}.
     private final View mOriginalView;
 
-    private final List<Animator> mAnimators = new ArrayList<>();
+    private final AnimatorSet mAnimators = new AnimatorSet();
 
     /**
      * @param floatingViewOriginalView The FloatingIconView's original view.
@@ -136,16 +131,9 @@
         addScrimAnimationForState(launcher, BACKGROUND_APP, 0);
         addScrimAnimationForState(launcher, NORMAL, ALPHA_DURATION_MS);
 
-        AnimatorListener resetClipListener = new AnimatorListenerAdapter() {
-            int numAnimations = mAnimators.size();
-
+        mAnimators.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
-                numAnimations--;
-                if (numAnimations > 0) {
-                    return;
-                }
-
                 workspace.setClipChildren(workspaceClipChildren);
                 workspace.setClipToPadding(workspaceClipToPadding);
                 cellLayout.setClipChildren(cellLayoutClipChildren);
@@ -153,24 +141,14 @@
                 hotseat.setClipChildren(hotseatClipChildren);
                 hotseat.setClipToPadding(hotseatClipToPadding);
             }
-        };
-
-        for (Animator a : mAnimators) {
-            a.addListener(resetClipListener);
-        }
+        });
     }
 
     /**
      * Starts the animation.
      */
     public void start() {
-        for (Animator a : mAnimators) {
-            if (a instanceof SpringObjectAnimator) {
-                ((SpringObjectAnimator) a).startSpring(1f, mVelocity, null);
-            } else {
-                a.start();
-            }
-        }
+        mAnimators.start();
     }
 
     /**
@@ -187,10 +165,16 @@
         long startDelay = (long) ((invertedRow + 1) * APP_CLOSE_ROW_START_DELAY_MS);
 
         v.setTranslationY(mSpringTransY);
-        SpringObjectAnimator springTransY = new SpringObjectAnimator<>(v, VIEW_TRANSLATE_Y,
-                1f, DAMPING_RATIO, STIFFNESS, mSpringTransY, 0);
+
+        ObjectAnimator springTransY = new SpringAnimationBuilder<>(v, VIEW_TRANSLATE_Y)
+                .setStiffness(STIFFNESS)
+                .setDampingRatio(DAMPING_RATIO)
+                .setMinimumVisibleChange(1f)
+                .setEndValue(0)
+                .setStartVelocity(mVelocity)
+                .build(v.getContext());
         springTransY.setStartDelay(startDelay);
-        mAnimators.add(springTransY);
+        mAnimators.play(springTransY);
 
         ObjectAnimator alpha = getAlphaAnimator(v, startDelay);
         if (v == mOriginalView) {
@@ -211,7 +195,7 @@
         }
 
         v.setAlpha(0);
-        mAnimators.add(alpha);
+        mAnimators.play(alpha);
     }
 
     private ObjectAnimator getAlphaAnimator(View v, long startDelay) {
@@ -229,11 +213,11 @@
         scrimAnimConfig.duration = duration;
         PropertySetter scrimPropertySetter = scrimAnimConfig.getPropertySetter(scrimAnimBuilder);
         launcher.getWorkspace().getStateTransitionAnimation().setScrim(scrimPropertySetter, state);
-        mAnimators.add(scrimAnimBuilder.build());
+        mAnimators.play(scrimAnimBuilder.build());
         Animator fadeOverviewScrim = ObjectAnimator.ofFloat(
                 launcher.getDragLayer().getOverviewScrim(), OverviewScrim.SCRIM_PROGRESS,
                 state.getOverviewScrimAlpha(launcher));
         fadeOverviewScrim.setDuration(duration);
-        mAnimators.add(fadeOverviewScrim);
+        mAnimators.play(fadeOverviewScrim);
     }
 }