diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index c5d0b952c2..e77d2c6e01 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1057,9 +1057,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW && BlurUtils.supportsBlursOnWindows(); - ObjectAnimator backgroundRadiusAnim = - ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth, - MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) + LaunchDepthController depthController = new LaunchDepthController(mLauncher); + ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController.stateDepth, + MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); if (allowBlurringLauncher) { @@ -1085,6 +1085,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener new SurfaceControl.Transaction().remove(dimLayer).apply())); } + backgroundRadiusAnim.addListener( + AnimatorListeners.forEndCallback(depthController::dispose)); + return backgroundRadiusAnim; } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 957db6414e..882682dc4a 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -94,6 +94,18 @@ public class DepthController extends BaseDepthController implements StateHandler } } + /** + * Cleans up after this controller so it can be garbage collected without leaving traces. + */ + public void dispose() { + removeSecondaryListeners(); + + if (mLauncher.getRootView() != null && mOnAttachListener != null) { + mLauncher.getRootView().removeOnAttachStateChangeListener(mOnAttachListener); + mOnAttachListener = null; + } + } + private void removeSecondaryListeners() { if (mCrossWindowBlurListener != null) { CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);