summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-06-28 17:12:20 +0800
committerOwen Lin <owenlin@google.com>2012-07-03 18:05:47 +0800
commit7aac26484af3d40df81e1d08c673bd925856a7fa (patch)
tree4f444fc13ca1ee651f2e5e75787b5f1c16cef9eb /src/com/android/gallery3d/ui
parentce8b4485801843c14abc3654e57aad96d1364e49 (diff)
downloadandroid_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.tar.gz
android_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.tar.bz2
android_packages_apps_Snap-7aac26484af3d40df81e1d08c673bd925856a7fa.zip
Don't reuse bitmap before HoneyComb.
Change-Id: I0df9bf0a8f43e28ed25b436d4c584dc3ceb43c1d
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java4
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java4
-rw-r--r--src/com/android/gallery3d/ui/BitmapScreenNail.java16
-rw-r--r--src/com/android/gallery3d/ui/GLRootView.java3
4 files changed, 17 insertions, 10 deletions
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 6561a23f3..449c6f9d3 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -23,6 +23,7 @@ import com.android.gallery3d.R;
import com.android.gallery3d.app.AlbumSetDataLoader;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.DataSourceType;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -423,7 +424,8 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
@Override
protected void recycleBitmap(Bitmap bitmap) {
- MediaItem.getMicroThumbPool().recycle(bitmap);
+ BitmapPool pool = MediaItem.getMicroThumbPool();
+ if (pool != null) pool.recycle(bitmap);
}
@Override
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index deec1712d..d5d90a9ea 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -22,6 +22,7 @@ import android.os.Message;
import com.android.gallery3d.app.AlbumDataLoader;
import com.android.gallery3d.app.GalleryActivity;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.util.Future;
@@ -277,7 +278,8 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
@Override
protected void recycleBitmap(Bitmap bitmap) {
- MediaItem.getMicroThumbPool().recycle(bitmap);
+ BitmapPool pool = MediaItem.getMicroThumbPool();
+ if (pool != null) pool.recycle(bitmap);
}
@Override
diff --git a/src/com/android/gallery3d/ui/BitmapScreenNail.java b/src/com/android/gallery3d/ui/BitmapScreenNail.java
index 5c917570d..0043e0cbe 100644
--- a/src/com/android/gallery3d/ui/BitmapScreenNail.java
+++ b/src/com/android/gallery3d/ui/BitmapScreenNail.java
@@ -20,6 +20,7 @@ import android.graphics.Bitmap;
import android.graphics.RectF;
import com.android.gallery3d.common.Utils;
+import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.MediaItem;
// This is a ScreenNail wraps a Bitmap. There are some extra functions:
@@ -70,6 +71,11 @@ public class BitmapScreenNail implements ScreenNail {
mHeight = Math.round(scale * height);
}
+ private static void recycleBitmap(BitmapPool pool, Bitmap bitmap) {
+ if (pool == null || bitmap == null) return;
+ pool.recycle(bitmap);
+ }
+
// Combines the two ScreenNails.
// Returns the used one and recycle the unused one.
public ScreenNail combine(ScreenNail other) {
@@ -88,9 +94,7 @@ public class BitmapScreenNail implements ScreenNail {
mWidth = newer.mWidth;
mHeight = newer.mHeight;
if (newer.mBitmap != null) {
- if (mBitmap != null) {
- MediaItem.getThumbPool().recycle(mBitmap);
- }
+ recycleBitmap(MediaItem.getThumbPool(), mBitmap);
mBitmap = newer.mBitmap;
newer.mBitmap = null;
@@ -130,10 +134,8 @@ public class BitmapScreenNail implements ScreenNail {
mTexture.recycle();
mTexture = null;
}
- if (mBitmap != null) {
- MediaItem.getThumbPool().recycle(mBitmap);
- mBitmap = null;
- }
+ recycleBitmap(MediaItem.getThumbPool(), mBitmap);
+ mBitmap = null;
}
@Override
diff --git a/src/com/android/gallery3d/ui/GLRootView.java b/src/com/android/gallery3d/ui/GLRootView.java
index 401ca59eb..fe4e19d7b 100644
--- a/src/com/android/gallery3d/ui/GLRootView.java
+++ b/src/com/android/gallery3d/ui/GLRootView.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.graphics.Matrix;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
+import android.os.Build;
import android.os.Process;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -536,7 +537,7 @@ public class GLRootView extends GLSurfaceView
}
@Override
- @TargetApi(ApiHelper.VERSION_CODES.JELLY_BEAN)
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setLightsOutMode(boolean enabled) {
int flags = 0;
if (enabled) {