summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/PagedViewWidget.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2011-09-20 14:22:40 -0700
committerWinson Chung <winsonc@google.com>2011-09-29 12:52:22 -0700
commit099459377a737d885bbd8ac4d52e6884a103b1c7 (patch)
tree53531d1624a41f25461e865cd82f4203ea57910b /src/com/android/launcher2/PagedViewWidget.java
parentc5d2a7b0d6b85999731cc82ff945635fdea1e670 (diff)
downloadandroid_packages_apps_Trebuchet-099459377a737d885bbd8ac4d52e6884a103b1c7.tar.gz
android_packages_apps_Trebuchet-099459377a737d885bbd8ac4d52e6884a103b1c7.tar.bz2
android_packages_apps_Trebuchet-099459377a737d885bbd8ac4d52e6884a103b1c7.zip
Clean up bitmaps when necessary in the widget tray to prevent likelihood of OOM. (Bug: 5348390)
- Removing some old code to use software layers when rendering widget preview metadata Change-Id: I0db3daf7d1223e81dac6c901647acbe2ff490c6e
Diffstat (limited to 'src/com/android/launcher2/PagedViewWidget.java')
-rw-r--r--src/com/android/launcher2/PagedViewWidget.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 053c2ea1a..4e06570fc 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -96,6 +96,20 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
setClipToPadding(false);
}
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+
+ final ImageView image = (ImageView) findViewById(R.id.widget_preview);
+ if (image != null) {
+ FastBitmapDrawable preview = (FastBitmapDrawable) image.getDrawable();
+ if (preview != null && preview.getBitmap() != null) {
+ preview.getBitmap().recycle();
+ }
+ image.setImageDrawable(null);
+ }
+ }
+
public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
FastBitmapDrawable preview, int maxWidth, int[] cellSpan,
HolographicOutlineHelper holoOutlineHelper) {
@@ -109,11 +123,9 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
mPreviewImageView = image;
final TextView name = (TextView) findViewById(R.id.widget_name);
name.setText(info.label);
- name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
final TextView dims = (TextView) findViewById(R.id.widget_dims);
if (dims != null) {
dims.setText(String.format(mDimensionsFormatString, cellSpan[0], cellSpan[1]));
- dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
@@ -127,11 +139,9 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
mPreviewImageView = image;
final TextView name = (TextView) findViewById(R.id.widget_name);
name.setText(label);
- name.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
final TextView dims = (TextView) findViewById(R.id.widget_dims);
if (dims != null) {
dims.setText(String.format(mDimensionsFormatString, 1, 1));
- dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}