Clean up device profile change listeners for AllApps.

Test: https://b.corp.google.com/issues/260177372#comment1
Bug: 260177372
Change-Id: Ic7417980e8280bf2fcb110e5de74ea2ae59d9b74
This commit is contained in:
Brian Isganitis
2023-03-29 14:06:41 -04:00
parent d48a6fb4b7
commit d17261029a
3 changed files with 31 additions and 3 deletions

View File

@@ -192,7 +192,6 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
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.
@@ -263,6 +262,18 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
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;
}