From 184fbe8646e6ddb438db2911a2dd506fc6f20176 Mon Sep 17 00:00:00 2001 From: yongga Date: Wed, 13 Jan 2016 17:03:27 +0800 Subject: Gallery2: Fix can't show the thumbnails when the storage full The NullPointerException occur and then it can't decode the thumbnails. Determine whether the reference is instantiated before invoking it. Change-Id: Id68da30d15c88eb029f83fbde25912b9e07ce062 CRs-Fixed: 954026 --- src/com/android/gallery3d/data/ImageCacheService.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/com') diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java index 1c7cb8c5e..129c113a6 100644 --- a/src/com/android/gallery3d/data/ImageCacheService.java +++ b/src/com/android/gallery3d/data/ImageCacheService.java @@ -62,6 +62,9 @@ public class ImageCacheService { LookupRequest request = new LookupRequest(); request.key = cacheKey; request.buffer = buffer.data; + if (mCache == null) { + return false; + } synchronized (mCache) { if (!mCache.lookup(request)) return false; } @@ -83,6 +86,9 @@ public class ImageCacheService { ByteBuffer buffer = ByteBuffer.allocate(key.length + value.length); buffer.put(key); buffer.put(value); + if (mCache == null) { + return; + } synchronized (mCache) { try { mCache.insert(cacheKey, buffer.array()); @@ -95,6 +101,9 @@ public class ImageCacheService { public void clearImageData(Path path, long timeModified, int type) { byte[] key = makeKey(path, timeModified, type); long cacheKey = Utils.crc64Long(key); + if (mCache == null) { + return; + } synchronized (mCache) { try { mCache.clearEntry(cacheKey); -- cgit v1.2.3