diff options
author | ztenghui <ztenghui@google.com> | 2013-07-18 14:40:10 -0700 |
---|---|---|
committer | ztenghui <ztenghui@google.com> | 2013-07-19 14:32:58 -0700 |
commit | d32b92d96ad07f15f6130a8608a67ab96c962a96 (patch) | |
tree | 65f64943cb29acd08c9622bc7065d4201384a243 /src/com/android/gallery3d/data/ImageCacheService.java | |
parent | 4264520a6a231d42f65168b07e7e793cda7b1a8d (diff) | |
download | android_packages_apps_Snap-d32b92d96ad07f15f6130a8608a67ab96c962a96.tar.gz android_packages_apps_Snap-d32b92d96ad07f15f6130a8608a67ab96c962a96.tar.bz2 android_packages_apps_Snap-d32b92d96ad07f15f6130a8608a67ab96c962a96.zip |
Update Uri instead of removing
In this way, the processing service can have a better presentation.
The cache key now include the file Uri and local abs path if exists.
bug:9468909
Change-Id: I0919c09ad26bea2e798c99ad376996547f8f2bf8
Diffstat (limited to 'src/com/android/gallery3d/data/ImageCacheService.java')
-rw-r--r-- | src/com/android/gallery3d/data/ImageCacheService.java | 19 |
1 files changed, 10 insertions, 9 deletions
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) { |