Fix a no-thumbnail error message.
This happens if we cancel the first image reqest and then resend another
in a very short time. We may got an null image for the first request and
think this is a invalid bitmap.
Change-Id: I9ab62a658c281ef3d197474a5db50579e560f1bd
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index 78afe7e..b976dec 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -214,11 +214,12 @@
private void updateScreenNail(long version, Future<Bitmap> future) {
ImageEntry entry = mImageCache.get(version);
- if (entry == null || entry.screenNailTask == null) {
+ if (entry == null || entry.screenNailTask != future) {
Bitmap screenNail = future.get();
if (screenNail != null) screenNail.recycle();
return;
}
+
entry.screenNailTask = null;
entry.screenNail = future.get();
@@ -240,11 +241,12 @@
private void updateFullImage(long version, Future<BitmapRegionDecoder> future) {
ImageEntry entry = mImageCache.get(version);
- if (entry == null || entry.fullImageTask == null) {
+ if (entry == null || entry.fullImageTask != future) {
BitmapRegionDecoder fullImage = future.get();
if (fullImage != null) fullImage.recycle();
return;
}
+
entry.fullImageTask = null;
entry.fullImage = future.get();
if (entry.fullImage != null) {
@@ -567,12 +569,14 @@
mVersion = version;
}
+ @Override
public void onFutureDone(Future<BitmapRegionDecoder> future) {
mFuture = future;
mMainHandler.sendMessage(
mMainHandler.obtainMessage(MSG_RUN_OBJECT, this));
}
+ @Override
public void run() {
updateFullImage(mVersion, mFuture);
}
@@ -587,12 +591,14 @@
mVersion = version;
}
+ @Override
public void onFutureDone(Future<Bitmap> future) {
mFuture = future;
mMainHandler.sendMessage(
mMainHandler.obtainMessage(MSG_RUN_OBJECT, this));
}
+ @Override
public void run() {
updateScreenNail(mVersion, mFuture);
}