summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/FilterShowActivity.java
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2013-03-11 18:37:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-03-11 18:37:56 +0000
commit7b5e88bf8ce55d9b5bd757eada579422cee2a246 (patch)
treec9bb00301298958ffbce38a95cffbeab55b84f23 /src/com/android/gallery3d/filtershow/FilterShowActivity.java
parent28bf7ac129344ca6306d83fc114759c9cf923806 (diff)
parent6320d90fb41fe1276a02b17fa27a660e76f21ba8 (diff)
downloadandroid_packages_apps_Snap-7b5e88bf8ce55d9b5bd757eada579422cee2a246.tar.gz
android_packages_apps_Snap-7b5e88bf8ce55d9b5bd757eada579422cee2a246.tar.bz2
android_packages_apps_Snap-7b5e88bf8ce55d9b5bd757eada579422cee2a246.zip
Merge "Clear Gallery's bitmap pool on photo editor start. Minor refactoring." into gb-ub-photos-bryce
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 1c7c0642a..9b1e92cd8 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -86,6 +86,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;
@@ -141,6 +142,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ clearGalleryBitmapPoolInBackground();
+
setupMasterImage();
setDefaultValues();
fillEditors();
@@ -512,6 +515,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) {
@@ -1125,7 +1146,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) {}
@@ -1134,6 +1155,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) {
@@ -1142,7 +1166,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() {