diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index 6b9f5a9d1e..e4e97e5a75 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -402,6 +402,16 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar view.setTag(null); } + /** Loop through all {@link FolderIcon} as child views and clear listeners to avoid leak. */ + public void removeFolderIconListeners() { + final int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + if (getChildAt(i) instanceof FolderIcon fi) { + fi.removeListeners(); + } + } + } + /** Inflates/binds the hotseat items and recent tasks to the view. */ protected void updateItems(ItemInfo[] hotseatItemInfos, List recentTasks) { // Filter out unsupported items. diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index e0be39dc0a..0f05887d45 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -365,6 +365,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar if (enableTaskbarPinning()) { mTaskbarView.removeOnLayoutChangeListener(mTaskbarViewLayoutChangeListener); } + mTaskbarView.removeFolderIconListeners(); LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks); mActivity.removeOnDeviceProfileChangeListener(mDeviceProfileChangeListener); }