summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/data')
-rw-r--r--src/com/android/gallery3d/data/ImageCacheRequest.java10
-rw-r--r--src/com/android/gallery3d/data/ImageCacheService.java19
-rw-r--r--src/com/android/gallery3d/data/LocalImage.java10
-rw-r--r--src/com/android/gallery3d/data/LocalVideo.java10
4 files changed, 28 insertions, 21 deletions
diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java
index 475614962..6cbc5c5ea 100644
--- a/src/com/android/gallery3d/data/ImageCacheRequest.java
+++ b/src/com/android/gallery3d/data/ImageCacheRequest.java
@@ -32,17 +32,19 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
private Path mPath;
private int mType;
private int mTargetSize;
+ private long mTimeModified;
public ImageCacheRequest(GalleryApp application,
- Path path, int type, int targetSize) {
+ Path path, long timeModified, int type, int targetSize) {
mApplication = application;
mPath = path;
mType = type;
mTargetSize = targetSize;
+ mTimeModified = timeModified;
}
private String debugTag() {
- return mPath + "," +
+ return mPath + "," + mTimeModified + "," +
((mType == MediaItem.TYPE_THUMBNAIL) ? "THUMB" :
(mType == MediaItem.TYPE_MICROTHUMBNAIL) ? "MICROTHUMB" : "?");
}
@@ -53,7 +55,7 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
BytesBuffer buffer = MediaItem.getBytesBufferPool().get();
try {
- boolean found = cacheService.getImageData(mPath, mType, buffer);
+ boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer);
if (jc.isCancelled()) return null;
if (found) {
BitmapFactory.Options options = new BitmapFactory.Options();
@@ -92,7 +94,7 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
byte[] array = BitmapUtils.compressToBytes(bitmap);
if (jc.isCancelled()) return null;
- cacheService.putImageData(mPath, mType, array);
+ cacheService.putImageData(mPath, mTimeModified, mType, array);
return bitmap;
}
diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java
index 527d6c8cd..1c7cb8c5e 100644
--- a/src/com/android/gallery3d/data/ImageCacheService.java
+++ b/src/com/android/gallery3d/data/ImageCacheService.java
@@ -46,7 +46,8 @@ public class ImageCacheService {
}
/**
- * Gets the cached image data for the given <code>path</code> and <code>type</code>.
+ * Gets the cached image data for the given <code>path</code>,
+ * <code>timeModified</code> and <code>type</code>.
*
* The image data will be stored in <code>buffer.data</code>, started from
* <code>buffer.offset</code> for <code>buffer.length</code> bytes. If the
@@ -54,8 +55,8 @@ public class ImageCacheService {
*
* @return true if the image data is found; false if not found.
*/
- public boolean getImageData(Path path, int type, BytesBuffer buffer) {
- byte[] key = makeKey(path, type);
+ public boolean getImageData(Path path, long timeModified, int type, BytesBuffer buffer) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
try {
LookupRequest request = new LookupRequest();
@@ -76,8 +77,8 @@ public class ImageCacheService {
return false;
}
- public void putImageData(Path path, int type, byte[] value) {
- byte[] key = makeKey(path, type);
+ public void putImageData(Path path, long timeModified, int type, byte[] value) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
ByteBuffer buffer = ByteBuffer.allocate(key.length + value.length);
buffer.put(key);
@@ -91,8 +92,8 @@ public class ImageCacheService {
}
}
- public void clearImageData(Path path, int type) {
- byte[] key = makeKey(path, type);
+ public void clearImageData(Path path, long timeModified, int type) {
+ byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
synchronized (mCache) {
try {
@@ -103,8 +104,8 @@ public class ImageCacheService {
}
}
- private static byte[] makeKey(Path path, int type) {
- return GalleryUtils.getBytes(path.toString() + "+" + type);
+ private static byte[] makeKey(Path path, long timeModified, int type) {
+ return GalleryUtils.getBytes(path.toString() + "+" + timeModified + "+" + type);
}
private static boolean isSameKey(byte[] key, byte[] buffer) {
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index eb1efae66..cc70dd457 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -173,15 +173,17 @@ public class LocalImage extends LocalMediaItem {
@Override
public Job<Bitmap> requestImage(int type) {
- return new LocalImageRequest(mApplication, mPath, type, filePath);
+ return new LocalImageRequest(mApplication, mPath, dateModifiedInSec,
+ type, filePath);
}
public static class LocalImageRequest extends ImageCacheRequest {
private String mLocalFilePath;
- LocalImageRequest(GalleryApp application, Path path, int type,
- String localFilePath) {
- super(application, path, type, MediaItem.getTargetSize(type));
+ LocalImageRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type));
mLocalFilePath = localFilePath;
}
diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java
index b1e1cb3aa..4b8774ca4 100644
--- a/src/com/android/gallery3d/data/LocalVideo.java
+++ b/src/com/android/gallery3d/data/LocalVideo.java
@@ -152,15 +152,17 @@ public class LocalVideo extends LocalMediaItem {
@Override
public Job<Bitmap> requestImage(int type) {
- return new LocalVideoRequest(mApplication, getPath(), type, filePath);
+ return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec,
+ type, filePath);
}
public static class LocalVideoRequest extends ImageCacheRequest {
private String mLocalFilePath;
- LocalVideoRequest(GalleryApp application, Path path, int type,
- String localFilePath) {
- super(application, path, type, MediaItem.getTargetSize(type));
+ LocalVideoRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type));
mLocalFilePath = localFilePath;
}