am c02e3932: Merge "Reduce peak memory use in PagedView"
* commit 'c02e3932c382a1854ff39c5e2714d5c07c0a8bcd':
Reduce peak memory use in PagedView
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 1d91f3c..2db03da 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1600,22 +1600,29 @@
int upperPageBound = getAssociatedUpperPageBound(page);
if (DEBUG) Log.d(TAG, "loadAssociatedPages: " + lowerPageBound + "/"
+ upperPageBound);
+ // First, clear any pages that should no longer be loaded
+ for (int i = 0; i < count; ++i) {
+ Page layout = (Page) getPageAt(i);
+ if ((immediateAndOnly && i != page) ||
+ (i < lowerPageBound) ||
+ (i > upperPageBound)) {
+ if (layout.getPageChildCount() > 0) {
+ layout.removeAllViewsOnPage();
+ }
+ mDirtyPageContent.set(i, true);
+ }
+ }
+ // Next, load any new pages
for (int i = 0; i < count; ++i) {
if ((i != page) && immediateAndOnly) {
continue;
}
Page layout = (Page) getPageAt(i);
- final int childCount = layout.getPageChildCount();
if (lowerPageBound <= i && i <= upperPageBound) {
if (mDirtyPageContent.get(i)) {
syncPageItems(i, (i == page) && immediateAndOnly);
mDirtyPageContent.set(i, false);
}
- } else {
- if (childCount > 0) {
- layout.removeAllViewsOnPage();
- }
- mDirtyPageContent.set(i, true);
}
}
}