am c02e3932: Merge "Reduce peak memory use in PagedView"

* commit 'c02e3932c382a1854ff39c5e2714d5c07c0a8bcd':
  Reduce peak memory use in PagedView
This commit is contained in:
Michael Jurka 2011-12-09 16:29:36 -08:00 committed by Android Git Automerger
commit 31c7b78662
1 changed files with 13 additions and 6 deletions

View File

@ -1600,22 +1600,29 @@ public abstract class PagedView extends ViewGroup {
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);
}
}
}