summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java b/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java
index 66ac4301f..307531d5b 100644
--- a/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java
+++ b/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java
@@ -34,6 +34,9 @@ public class MtpBitmapCache extends LruCache<Integer, Bitmap> {
public synchronized static void onDeviceDisconnected(MtpDevice device) {
if (sInstance != null && sInstance.mDevice == device) {
+ synchronized (sInstance) {
+ sInstance.mDevice = null;
+ }
sInstance = null;
}
}
@@ -56,7 +59,13 @@ public class MtpBitmapCache extends LruCache<Integer, Bitmap> {
}
private Bitmap createAndInsert(Integer key) {
- byte[] imageBytes = mDevice.getThumbnail(key);
+ MtpDevice device;
+ synchronized (this) {
+ device = mDevice;
+ }
+ if (device == null) return null;
+ byte[] imageBytes = device.getThumbnail(key);
+ if (imageBytes == null) return null;
Bitmap created = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
put(key, created);
return created;