summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/MediaItem.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-03-07 17:39:56 +0800
committerOwen Lin <owenlin@google.com>2012-03-14 15:48:54 +0800
commit4bb5912e85f6d1bd8a6b78d6d52b4c4da7aeb740 (patch)
treedf0b40113c30443abe15cdb7d364bf80591c4686 /src/com/android/gallery3d/data/MediaItem.java
parentd5617d5d6a5f4b0c0f68b2fda5a587b8272ca5c2 (diff)
downloadandroid_packages_apps_Gallery2-4bb5912e85f6d1bd8a6b78d6d52b4c4da7aeb740.tar.gz
android_packages_apps_Gallery2-4bb5912e85f6d1bd8a6b78d6d52b4c4da7aeb740.tar.bz2
android_packages_apps_Gallery2-4bb5912e85f6d1bd8a6b78d6d52b4c4da7aeb740.zip
Reuse bitmap for all micro thumb images to prevent GC.
Change-Id: I27d3002e5bb745a597f52962fe24744c8329441c
Diffstat (limited to 'src/com/android/gallery3d/data/MediaItem.java')
-rw-r--r--src/com/android/gallery3d/data/MediaItem.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/data/MediaItem.java b/src/com/android/gallery3d/data/MediaItem.java
index 13612321c..b682c2d1b 100644
--- a/src/com/android/gallery3d/data/MediaItem.java
+++ b/src/com/android/gallery3d/data/MediaItem.java
@@ -16,11 +16,11 @@
package com.android.gallery3d.data;
-import com.android.gallery3d.util.ThreadPool.Job;
-
import android.graphics.Bitmap;
import android.graphics.BitmapRegionDecoder;
+import com.android.gallery3d.util.ThreadPool.Job;
+
// MediaItem represents an image or a video item.
public abstract class MediaItem extends MediaObject {
// NOTE: These type numbers are stored in the image cache, so it should not
@@ -89,4 +89,16 @@ public abstract class MediaItem extends MediaObject {
// Returns 0, 0 if the information is not available.
public abstract int getWidth();
public abstract int getHeight();
+
+ public static int getTargetSize(int type) {
+ switch (type) {
+ case TYPE_THUMBNAIL:
+ return THUMBNAIL_TARGET_SIZE;
+ case TYPE_MICROTHUMBNAIL:
+ return MICROTHUMBNAIL_TARGET_SIZE;
+ default:
+ throw new RuntimeException(
+ "should only request thumb/microthumb from cache");
+ }
+ }
}