RecentsView - reduce work in color tint animator
Don't allocate animators when there is no animation to do. The work was
not required.
Bug: 189492167
Test: Local build, run and trace analysis
Change-Id: I111768b055ed636aa92d5d9d6b799f316a568380
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index a0bba86..a4c60cf 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -410,6 +410,7 @@
// TODO(b/187528071): Remove these and replace with a real scrim.
private float mColorTint;
private final int mTintingColor;
+ private ObjectAnimator mTintingAnimator;
private int mOverScrollShift = 0;
@@ -3693,9 +3694,17 @@
* tasks to be dimmed while other elements in the recents view are left alone.
*/
public void showForegroundScrim(boolean show) {
- ObjectAnimator anim = ObjectAnimator.ofFloat(this, COLOR_TINT, show ? 0.5f : 0f);
- anim.setAutoCancel(true);
- anim.start();
+ if (!show && mColorTint == 0) {
+ if (mTintingAnimator != null) {
+ mTintingAnimator.cancel();
+ mTintingAnimator = null;
+ }
+ return;
+ }
+
+ mTintingAnimator = ObjectAnimator.ofFloat(this, COLOR_TINT, show ? 0.5f : 0f);
+ mTintingAnimator.setAutoCancel(true);
+ mTintingAnimator.start();
}
/** Tint the RecentsView and TaskViews in to simulate a scrim. */