diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 121afb060a..ed834b9c89 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -90,7 +90,7 @@ class AsyncTaskPageData { if (generatedImages != null) { if (cancelled) { for (int i = 0; i < generatedImages.size(); i++) { - widgetPreviewLoader.releaseBitmap(items.get(i), generatedImages.get(i)); + widgetPreviewLoader.recycleBitmap(items.get(i), generatedImages.get(i)); } } generatedImages.clear(); diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 5eb8483061..27ceaba29d 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -264,15 +264,19 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona // Animate the transition ObjectAnimator outAnim = LauncherAnimUtils.ofFloat(mAnimationBuffer, "alpha", 0f); outAnim.addListener(new AnimatorListenerAdapter() { + private void clearAnimationBuffer() { + mAnimationBuffer.setVisibility(View.GONE); + PagedViewWidget.setRecyclePreviewsWhenDetachedFromWindow(false); + mAnimationBuffer.removeAllViews(); + PagedViewWidget.setRecyclePreviewsWhenDetachedFromWindow(true); + } @Override public void onAnimationEnd(Animator animation) { - mAnimationBuffer.setVisibility(View.GONE); - mAnimationBuffer.removeAllViews(); + clearAnimationBuffer(); } @Override public void onAnimationCancel(Animator animation) { - mAnimationBuffer.setVisibility(View.GONE); - mAnimationBuffer.removeAllViews(); + clearAnimationBuffer(); } }); ObjectAnimator inAnim = LauncherAnimUtils.ofFloat(mAppsCustomizePane, "alpha", 1f); diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index aece398a22..bb5827ae75 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -38,6 +38,7 @@ public class PagedViewWidget extends LinearLayout { static final String TAG = "PagedViewWidgetLayout"; private static boolean sDeletePreviewsWhenDetachedFromWindow = true; + private static boolean sRecyclePreviewsWhenDetachedFromWindow = true; private String mDimensionsFormatString; CheckForShortPress mPendingCheckForShortPress = null; @@ -82,6 +83,10 @@ public class PagedViewWidget extends LinearLayout { sDeletePreviewsWhenDetachedFromWindow = value; } + public static void setRecyclePreviewsWhenDetachedFromWindow(boolean value) { + sRecyclePreviewsWhenDetachedFromWindow = value; + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); @@ -90,8 +95,9 @@ public class PagedViewWidget extends LinearLayout { final ImageView image = (ImageView) findViewById(R.id.widget_preview); if (image != null) { FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable(); - if (mInfo != null && preview != null && preview.getBitmap() != null) { - mWidgetPreviewLoader.releaseBitmap(mInfo, preview.getBitmap()); + if (sRecyclePreviewsWhenDetachedFromWindow && + mInfo != null && preview != null && preview.getBitmap() != null) { + mWidgetPreviewLoader.recycleBitmap(mInfo, preview.getBitmap()); } image.setImageDrawable(null); } diff --git a/src/com/android/launcher2/WidgetPreviewLoader.java b/src/com/android/launcher2/WidgetPreviewLoader.java index a9bc098dcc..617879bb71 100644 --- a/src/com/android/launcher2/WidgetPreviewLoader.java +++ b/src/com/android/launcher2/WidgetPreviewLoader.java @@ -234,15 +234,14 @@ public class WidgetPreviewLoader { } } - public void releaseBitmap(Object o, Bitmap bitmapToFree) { - // enable this code when doDecode doesn't force Bitmaps to become immutable + public void recycleBitmap(Object o, Bitmap bitmapToRecycle) { String name = getObjectName(o); synchronized(mLoadedPreviews) { synchronized(mUnusedBitmaps) { Bitmap b = mLoadedPreviews.get(name).get(); - if (b == bitmapToFree) { + if (b == bitmapToRecycle) { mLoadedPreviews.remove(name); - if (bitmapToFree.isMutable()) { + if (bitmapToRecycle.isMutable()) { mUnusedBitmaps.add(new SoftReference(b)); } } else {