Back to project page AndroidImageCache.
The source code is released under:
Przemys?aw Jakubczyk Polidea Sp. z o.o. Copyright (c) 2012 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the follo...
If you think the Android project AndroidImageCache listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pl.polidea.webimageview; //w w w . j a va2s . c o m import android.graphics.Bitmap; import android.os.Handler; import android.os.Looper; import android.widget.ImageView; /** * @author Mateusz Grzechoci?ski <mateusz.grzechocinski@gmail.com> */ public class ImageViewUpdater { private final Handler handler; private final ImageView imageView; private String currentURL; public ImageViewUpdater(ImageView imageView) { this.imageView = imageView; handler = new Handler(Looper.getMainLooper()); } public synchronized void setCurrentURL(String url) { currentURL = url; } public synchronized void setBitmap(final String key, final Bitmap bitmap, final WebImageListener webImageListener) { if (key.equals(currentURL) && bitmap != null && !bitmap.isRecycled()) { handler.post(new RunnableImplementation(bitmap)); } webImageListener.onImageFetchedSuccessfully(currentURL); } private final class RunnableImplementation implements Runnable { private final Bitmap bitmap; private RunnableImplementation(final Bitmap bitmap) { this.bitmap = bitmap; } @Override public void run() { imageView.setImageBitmap(bitmap); } } }