summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/FilterShowActivity.java
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2013-03-11 09:53:16 -0700
committerRuben Brunk <rubenbrunk@google.com>2013-03-11 11:19:39 -0700
commit6320d90fb41fe1276a02b17fa27a660e76f21ba8 (patch)
tree59050c84f9aa98a0eed6f2f61586bae355402cc5 /src/com/android/gallery3d/filtershow/FilterShowActivity.java
parent976e017fa90c7134ef62cd69f61bbc08315b6042 (diff)
downloadandroid_packages_apps_Snap-6320d90fb41fe1276a02b17fa27a660e76f21ba8.tar.gz
android_packages_apps_Snap-6320d90fb41fe1276a02b17fa27a660e76f21ba8.tar.bz2
android_packages_apps_Snap-6320d90fb41fe1276a02b17fa27a660e76f21ba8.zip
Clear Gallery's bitmap pool on photo editor start. Minor refactoring.
Change-Id: I02e29bf6cfd85a9cecd3850f8828cccae91badd2
Diffstat (limited to 'src/com/android/gallery3d/filtershow/FilterShowActivity.java')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index e36a3841e..d6a49ebe5 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -91,6 +91,7 @@ import com.android.gallery3d.filtershow.ui.FilterIconButton;
import com.android.gallery3d.filtershow.ui.FramedTextButton;
import com.android.gallery3d.filtershow.ui.Spline;
import com.android.gallery3d.util.GalleryUtils;
+import com.android.photos.data.GalleryBitmapPool;
import java.io.File;
import java.io.IOException;
@@ -146,6 +147,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ clearGalleryBitmapPoolInBackground();
+
setupMasterImage();
setDefaultValues();
fillEditors();
@@ -508,6 +511,24 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
}
+ void clearGalleryBitmapPoolInBackground() {
+ BitmapTask.Callbacks<Object, Object> cb = new BitmapTask.Callbacks<Object, Object>() {
+ @Override
+ public void onComplete(Object result) {}
+
+ @Override
+ public void onCancel() {}
+
+ @Override
+ public Object onExecute(Object param) {
+ // Free memory held in Gallery's Bitmap pool. May be O(n) for n bitmaps.
+ GalleryBitmapPool.getInstance().clear();
+ return null;
+ }
+ };
+ (new BitmapTask<Object, Object>(cb)).execute(0);
+ }
+
private void fillButtonIcons() {
Bitmap bmap = mImageLoader.getOriginalBitmapSmall();
if (bmap != null && bmap.getWidth() > 0 && bmap.getHeight() > 0) {
@@ -1121,7 +1142,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
void setWallpaperInBackground(final Bitmap bmap) {
Toast.makeText(this, R.string.setting_wallpaper, Toast.LENGTH_LONG).show();
- BitmapTask.Callbacks<FilterShowActivity> cb = new BitmapTask.Callbacks<FilterShowActivity>() {
+ BitmapTask.Callbacks<FilterShowActivity, Bitmap> cb = new BitmapTask.Callbacks<FilterShowActivity, Bitmap>() {
@Override
public void onComplete(Bitmap result) {}
@@ -1130,6 +1151,9 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
@Override
public Bitmap onExecute(FilterShowActivity param) {
+ if (param == null) {
+ return null;
+ }
try {
WallpaperManager.getInstance(param).setBitmap(bmap);
} catch (IOException e) {
@@ -1138,7 +1162,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
return null;
}
};
- (new BitmapTask<FilterShowActivity>(cb)).execute(this);
+ (new BitmapTask<FilterShowActivity, Bitmap>(cb)).execute(this);
}
public void done() {