diff options
author | Michael Jurka <mikejurka@google.com> | 2012-06-02 15:30:26 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-02 15:30:26 -0700 |
commit | e766e1f57b00910442b52d7d11ba808a6b212459 (patch) | |
tree | 5c757bc5754d9350051fff914efc079612cf48a0 /packages | |
parent | d672b241f6720201e3b8f613363d71e4291b8597 (diff) | |
parent | 261277e1783ccebe5cb40763f8ef20d988dfe4ca (diff) | |
download | frameworks_base-e766e1f57b00910442b52d7d11ba808a6b212459.zip frameworks_base-e766e1f57b00910442b52d7d11ba808a6b212459.tar.gz frameworks_base-e766e1f57b00910442b52d7d11ba808a6b212459.tar.bz2 |
Merge "Reduce recents memory usage" into jb-dev
Diffstat (limited to 'packages')
3 files changed, 24 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java index 1302c1f..e1abb23 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java @@ -73,10 +73,16 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView return mLinearLayout.getWidth() - getWidth(); } + private void addToRecycledViews(View v) { + if (mRecycledViews.size() < mNumItemsInOneScreenful) { + mRecycledViews.add(v); + } + } + private void update() { for (int i = 0; i < mLinearLayout.getChildCount(); i++) { View v = mLinearLayout.getChildAt(i); - mRecycledViews.add(v); + addToRecycledViews(v); mAdapter.recycleView(v); } LayoutTransition transitioner = getLayoutTransition(); @@ -187,7 +193,7 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView } public void onChildDismissed(View v) { - mRecycledViews.add(v); + addToRecycledViews(v); mLinearLayout.removeView(v); if (v.getParent() != null) { throw new RuntimeException("Recycled child has parent"); @@ -362,13 +368,13 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView child.measure(childWidthMeasureSpec, childheightMeasureSpec); mNumItemsInOneScreenful = (int) FloatMath.ceil(dm.widthPixels / (float) child.getMeasuredWidth()); - mRecycledViews.add(child); + addToRecycledViews(child); if (child.getParent() != null) { throw new RuntimeException("First recycled child has parent"); } for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) { - mRecycledViews.add(mAdapter.createView(mLinearLayout)); + addToRecycledViews(mAdapter.createView(mLinearLayout)); if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) { throw new RuntimeException("Recycled child has parent"); } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java index 6bd1826..9bc54cb 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsScrollViewPerformanceHelper.java @@ -78,9 +78,10 @@ public class RecentsScrollViewPerformanceHelper { public void addViewCallback(View newLinearLayoutChild) { if (mSoftwareRendered && OPTIMIZE_SW_RENDERED_RECENTS) { - final View view = newLinearLayoutChild; - view.setDrawingCacheEnabled(true); - view.buildDrawingCache(); + final RecentsPanelView.ViewHolder holder = + (RecentsPanelView.ViewHolder) newLinearLayoutChild.getTag(); + holder.labelView.setDrawingCacheEnabled(true); + holder.labelView.buildDrawingCache(); } } diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java index f682203..33d2a75 100644 --- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java +++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java @@ -74,10 +74,16 @@ public class RecentsVerticalScrollView extends ScrollView return mLinearLayout.getHeight() - getHeight(); } + private void addToRecycledViews(View v) { + if (mRecycledViews.size() < mNumItemsInOneScreenful) { + mRecycledViews.add(v); + } + } + private void update() { for (int i = 0; i < mLinearLayout.getChildCount(); i++) { View v = mLinearLayout.getChildAt(i); - mRecycledViews.add(v); + addToRecycledViews(v); mAdapter.recycleView(v); } LayoutTransition transitioner = getLayoutTransition(); @@ -203,7 +209,7 @@ public class RecentsVerticalScrollView extends ScrollView } public void onChildDismissed(View v) { - mRecycledViews.add(v); + addToRecycledViews(v); mLinearLayout.removeView(v); if (v.getParent() != null) { throw new RuntimeException("Recycled child has parent"); @@ -380,13 +386,13 @@ public class RecentsVerticalScrollView extends ScrollView child.measure(childWidthMeasureSpec, childheightMeasureSpec); mNumItemsInOneScreenful = (int) FloatMath.ceil(dm.heightPixels / (float) child.getMeasuredHeight()); - mRecycledViews.add(child); + addToRecycledViews(child); if (child.getParent() != null) { throw new RuntimeException("First recycled child has parent"); } for (int i = 0; i < mNumItemsInOneScreenful - 1; i++) { - mRecycledViews.add(mAdapter.createView(mLinearLayout)); + addToRecycledViews(mAdapter.createView(mLinearLayout)); if (mRecycledViews.get(mRecycledViews.size() - 1).getParent() != null) { throw new RuntimeException("Recycled child has parent"); } |