diff options
author | Michael Jurka <mikejurka@google.com> | 2013-02-07 13:27:06 +0100 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2013-02-07 13:27:30 +0100 |
commit | ee8e99fe3bde78885904b4d9ea789b4d2a6f2b16 (patch) | |
tree | 619f1819c163aae712acf088b7803cd0dd605342 /src | |
parent | b81e22ef4a95185dc5453a4156c6bcad9417a3d1 (diff) | |
download | android_packages_apps_Trebuchet-ee8e99fe3bde78885904b4d9ea789b4d2a6f2b16.tar.gz android_packages_apps_Trebuchet-ee8e99fe3bde78885904b4d9ea789b4d2a6f2b16.tar.bz2 android_packages_apps_Trebuchet-ee8e99fe3bde78885904b4d9ea789b4d2a6f2b16.zip |
Fix crash when switching between Apps/Widgets tabs
Bug: 8138894
Diffstat (limited to 'src')
4 files changed, 20 insertions, 11 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 121afb060..ed834b9c8 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 5eb848306..27ceaba29 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() { - @Override - public void onAnimationEnd(Animator animation) { + private void clearAnimationBuffer() { mAnimationBuffer.setVisibility(View.GONE); + PagedViewWidget.setRecyclePreviewsWhenDetachedFromWindow(false); mAnimationBuffer.removeAllViews(); + PagedViewWidget.setRecyclePreviewsWhenDetachedFromWindow(true); + } + @Override + public void onAnimationEnd(Animator animation) { + 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 aece398a2..bb5827ae7 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 a9bc098dc..617879bb7 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<Bitmap>(b)); } } else { |