/** * 根据web地址,加载图片 * * @param path 图片的web url */ public void loadImageFromWeb(String webUrl, ImageLoadListener listener) { if (webUrl != null) { Bitmap result = getBitmapFromMemCache(webUrl); if (result == null) { addLoadWebImageThreadInPool(webUrl, listener); } else { listener.onLoaded(result); } } else { listener.onLoaded(null); } }
/** * 从sd卡中载入图片 * * @param sdCardPath * @param listener */ public void loadImageFromSdCard(String sdCardPath, ImageLoadListener listener) { if (sdCardPath != null) { Bitmap result = getBitmapFromMemCache(sdCardPath); if (result == null) { // 从sd卡中载入图片并缓存起来 addLoadSdImageThreadInPool(sdCardPath, listener); } else { listener.onLoaded(result); } } else { listener.onLoaded(null); } }
/** * Method is called when the bitmap is loaded. The UI thread adds the bitmap to the imageview. * * @param aViewSwitcher - The ViewSwitcher that needs to display the imageview * @param aImageView - The ImageView the UI thread will load * @param aImage - The Bitmap that gets loaded into the ImageView */ private void signalUI(final ViewHolder holder, final FileElem elem, Bitmap aImage) { if (mListener != null) { // we have an object that implements ImageLoadListener mListener.handleImageLoaded(holder, elem, aImage); } }
@Override public void run() { if (imageLoadListener == null) { if (imagePath.equals(imageView.getTag())) { imageView.setImageBitmap(bitmap); } } else { imageLoadListener.onLoadSucceed(imageView, bitmap, imagePath); } }