Merge "Remove redundant instances of depth controller." into udc-dev am: f898ee474c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23390637

Change-Id: I68a21468cc1b8856da74fe6bee1bff7c3a4aee95
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Luca Zuccarini
2023-05-24 12:16:46 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 2 deletions
@@ -1065,6 +1065,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
new SurfaceControl.Transaction().remove(dimLayer).apply())); new SurfaceControl.Transaction().remove(dimLayer).apply()));
} }
backgroundRadiusAnim.addListener(
AnimatorListeners.forEndCallback(depthController::dispose));
return backgroundRadiusAnim; return backgroundRadiusAnim;
} }
@@ -84,8 +84,7 @@ public class DepthController extends BaseDepthController implements StateHandler
@Override @Override
public void onViewDetachedFromWindow(View view) { public void onViewDetachedFromWindow(View view) {
CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener); removeSecondaryListeners();
mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener);
} }
}; };
rootView.addOnAttachStateChangeListener(mOnAttachListener); rootView.addOnAttachStateChangeListener(mOnAttachListener);
@@ -95,6 +94,27 @@ 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);
}
if (mOpaquenessListener != null) {
mLauncher.getScrimView().removeOpaquenessListener(mOpaquenessListener);
}
}
/** /**
* Sets if the underlying activity is started or not * Sets if the underlying activity is started or not
*/ */