Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a small improvement that should prevent showing a wrong bitmap in the recycled view #85

Merged
merged 1 commit into from
Oct 28, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ final class DisplayBitmapTask implements Runnable {
private final ImageView imageView;
private final BitmapDisplayer bitmapDisplayer;
private final ImageLoadingListener listener;
private final String memoryCacheKey;

public DisplayBitmapTask(Bitmap bitmap, ImageView imageView, BitmapDisplayer bitmapDisplayer, ImageLoadingListener listener) {
public DisplayBitmapTask(Bitmap bitmap, ImageView imageView, BitmapDisplayer bitmapDisplayer, ImageLoadingListener listener, String memoryCacheKey) {
this.bitmap = bitmap;
this.imageView = imageView;
this.bitmapDisplayer = bitmapDisplayer;
this.listener = listener;
this.memoryCacheKey = memoryCacheKey;
}

public void run() {
Bitmap displayedBitmap = bitmapDisplayer.display(bitmap, imageView);
listener.onLoadingComplete(displayedBitmap);
String currentCacheKey = ImageLoader.getInstance().getLoadingUriForView(imageView);
if (memoryCacheKey.equals(currentCacheKey)) {
Bitmap displayedBitmap = bitmapDisplayer.display(bitmap, imageView);
listener.onLoadingComplete(displayedBitmap);
} else {
listener.onLoadingCancelled();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void run() {
if (configuration.loggingEnabled) Log.i(ImageLoader.TAG, String.format(LOG_DISPLAY_IMAGE_IN_IMAGEVIEW, imageLoadingInfo.memoryCacheKey));

DisplayBitmapTask displayBitmapTask = new DisplayBitmapTask(bmp, imageLoadingInfo.imageView, imageLoadingInfo.options.getDisplayer(),
imageLoadingInfo.listener);
imageLoadingInfo.listener, imageLoadingInfo.memoryCacheKey);
handler.post(displayBitmapTask);
}

Expand Down