All apps memory leak fix / unregister data observer
Bug: 197702957
Test: adb shell dumpsys meminfo com.google.android.apps.nexuslauncher, ahat
Change-Id: Ia5732cced959e4a199d9c2b59f1f3941a2e23552
Merged-In: Ia5732cced959e4a199d9c2b59f1f3941a2e23552
(cherry picked from commit 6e72c8bbba
)
This commit is contained in:
parent
0a2076e8d3
commit
349c7c82f4
|
@ -499,8 +499,10 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
||||||
|
|
||||||
private void replaceRVContainer(boolean showTabs) {
|
private void replaceRVContainer(boolean showTabs) {
|
||||||
for (int i = 0; i < mAH.length; i++) {
|
for (int i = 0; i < mAH.length; i++) {
|
||||||
if (mAH[i].recyclerView != null) {
|
AllAppsRecyclerView rv = mAH[i].recyclerView;
|
||||||
mAH[i].recyclerView.setLayoutManager(null);
|
if (rv != null) {
|
||||||
|
rv.setLayoutManager(null);
|
||||||
|
rv.setAdapter(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
View oldView = getRecyclerViewContainer();
|
View oldView = getRecyclerViewContainer();
|
||||||
|
|
|
@ -63,6 +63,13 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
|
||||||
private final SparseIntArray mCachedScrollPositions = new SparseIntArray();
|
private final SparseIntArray mCachedScrollPositions = new SparseIntArray();
|
||||||
private final AllAppsFastScrollHelper mFastScrollHelper;
|
private final AllAppsFastScrollHelper mFastScrollHelper;
|
||||||
|
|
||||||
|
|
||||||
|
private final AdapterDataObserver mObserver = new RecyclerView.AdapterDataObserver() {
|
||||||
|
public void onChanged() {
|
||||||
|
mCachedScrollPositions.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// The empty-search result background
|
// The empty-search result background
|
||||||
private AllAppsBackgroundDrawable mEmptySearchBackground;
|
private AllAppsBackgroundDrawable mEmptySearchBackground;
|
||||||
private int mEmptySearchBackgroundTopOffset;
|
private int mEmptySearchBackgroundTopOffset;
|
||||||
|
@ -247,12 +254,13 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAdapter(Adapter adapter) {
|
public void setAdapter(Adapter adapter) {
|
||||||
|
if (getAdapter() != null) {
|
||||||
|
getAdapter().unregisterAdapterDataObserver(mObserver);
|
||||||
|
}
|
||||||
super.setAdapter(adapter);
|
super.setAdapter(adapter);
|
||||||
adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
if (adapter != null) {
|
||||||
public void onChanged() {
|
adapter.registerAdapterDataObserver(mObserver);
|
||||||
mCachedScrollPositions.clear();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue