diff options
author | Owen Lin <owenlin@google.com> | 2012-03-07 17:39:56 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-03-14 15:48:54 +0800 |
commit | 4bb5912e85f6d1bd8a6b78d6d52b4c4da7aeb740 (patch) | |
tree | df0b40113c30443abe15cdb7d364bf80591c4686 /src/com/android/gallery3d/data/LocalImage.java | |
parent | d5617d5d6a5f4b0c0f68b2fda5a587b8272ca5c2 (diff) | |
download | android_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/LocalImage.java')
-rw-r--r-- | src/com/android/gallery3d/data/LocalImage.java | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index fa3ece3b6..4f2797e02 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -16,13 +16,6 @@ package com.android.gallery3d.data; -import com.android.gallery3d.app.GalleryApp; -import com.android.gallery3d.common.BitmapUtils; -import com.android.gallery3d.util.GalleryUtils; -import com.android.gallery3d.util.ThreadPool.Job; -import com.android.gallery3d.util.ThreadPool.JobContext; -import com.android.gallery3d.util.UpdateHelper; - import android.content.ContentResolver; import android.content.ContentValues; import android.database.Cursor; @@ -35,6 +28,13 @@ import android.provider.MediaStore.Images; import android.provider.MediaStore.Images.ImageColumns; import android.util.Log; +import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.common.BitmapUtils; +import com.android.gallery3d.util.GalleryUtils; +import com.android.gallery3d.util.ThreadPool.Job; +import com.android.gallery3d.util.ThreadPool.JobContext; +import com.android.gallery3d.util.UpdateHelper; + import java.io.File; import java.io.IOException; @@ -159,14 +159,15 @@ public class LocalImage extends LocalMediaItem { LocalImageRequest(GalleryApp application, Path path, int type, String localFilePath) { - super(application, path, type, getTargetSize(type)); + super(application, path, type, MediaItem.getTargetSize(type)); mLocalFilePath = localFilePath; } @Override - public Bitmap onDecodeOriginal(JobContext jc, int type) { + public Bitmap onDecodeOriginal(JobContext jc, final int type) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; + int targetSize = MediaItem.getTargetSize(type); // try to decode from JPEG EXIF if (type == MediaItem.TYPE_MICROTHUMBNAIL) { @@ -181,25 +182,13 @@ public class LocalImage extends LocalMediaItem { Log.w(TAG, "fail to get exif thumb", t); } if (thumbData != null) { - Bitmap bitmap = DecodeUtils.requestDecodeIfBigEnough( - jc, thumbData, options, getTargetSize(type)); + Bitmap bitmap = DecodeUtils.decodeIfBigEnough( + jc, thumbData, options, targetSize); if (bitmap != null) return bitmap; } } - return DecodeUtils.requestDecode( - jc, mLocalFilePath, options, getTargetSize(type)); - } - } - 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"); + return DecodeUtils.decodeThumbnail(jc, mLocalFilePath, options, targetSize, type); } } @@ -217,8 +206,7 @@ public class LocalImage extends LocalMediaItem { } public BitmapRegionDecoder run(JobContext jc) { - return DecodeUtils.requestCreateBitmapRegionDecoder( - jc, mLocalFilePath, false); + return DecodeUtils.createBitmapRegionDecoder(jc, mLocalFilePath, false); } } |