From d43d7c37025f3eccc8a41a599ec4380720ff63b5 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Wed, 29 Mar 2023 14:06:41 -0400 Subject: [PATCH] Clean up device profile change listeners for AllApps. Test: https://b.corp.google.com/issues/260177372#comment1 Bug: 260177372 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d17261029af89ef03b860686d1d3c6651e7c8e13) Merged-In: Ic7417980e8280bf2fcb110e5de74ea2ae59d9b74 Change-Id: Ic7417980e8280bf2fcb110e5de74ea2ae59d9b74 --- .../launcher3/appprediction/PredictionRowView.java | 8 +++++++- .../taskbar/allapps/TaskbarAllAppsSlideInView.java | 10 ++++++++++ .../allapps/ActivityAllAppsContainerView.java | 13 ++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java index e8f2496e6e..3510fbef38 100644 --- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -76,7 +76,6 @@ public class PredictionRowView mFocusHelper = new SimpleFocusIndicatorHelper(this); mActivityContext = ActivityContext.lookupContext(context); - mActivityContext.addOnDeviceProfileChangeListener(this); mNumPredictedAppsPerRow = mActivityContext.getDeviceProfile().numShownAllAppsColumns; updateVisibility(); } @@ -84,6 +83,13 @@ public class PredictionRowView @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); + mActivityContext.addOnDeviceProfileChangeListener(this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mActivityContext.removeOnDeviceProfileChangeListener(this); } public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) { diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 8502752652..c1597b6507 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -99,10 +99,20 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView onAppsUpdated); } mAllAppsStore.addUpdateListener(onAppsUpdated); - mActivityContext.addOnDeviceProfileChangeListener(this); // This is a focus listener that proxies focus from a view into the list view. This is to // work around the search box from getting first focus and showing the cursor. @@ -262,6 +261,18 @@ public class ActivityAllAppsContainerView mSearchUiManager.initializeSearch(this); } + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mActivityContext.addOnDeviceProfileChangeListener(this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + mActivityContext.removeOnDeviceProfileChangeListener(this); + } + public SearchUiManager getSearchUiManager() { return mSearchUiManager; }