Universal-Image-Loader源码阅读(36)-DisplayBitmapTask
来源:互联网 发布:mac怎么用滑动 编辑:程序博客网 时间:2024/06/03 22:06
显示图片任务。
改种任务,直接显示图片,不需要先加载(已经加载过了)。
源码:
/** * Displays bitmap in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}. Must be called on UI thread. * * @author Sergey Tarasevich (nostra13[at]gmail[dot]com) * @see ImageLoadingListener * @see BitmapDisplayer * @since 1.3.1 */final class DisplayBitmapTask implements Runnable {private static final String LOG_DISPLAY_IMAGE_IN_IMAGEAWARE = "Display image in ImageAware (loaded from %1$s) [%2$s]";private static final String LOG_TASK_CANCELLED_IMAGEAWARE_REUSED = "ImageAware is reused for another image. Task is cancelled. [%s]";private static final String LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED = "ImageAware was collected by GC. Task is cancelled. [%s]";private final Bitmap bitmap;private final String imageUri;private final ImageAware imageAware;private final String memoryCacheKey;private final BitmapDisplayer displayer;private final ImageLoadingListener listener;private final ImageLoaderEngine engine;private final LoadedFrom loadedFrom;public DisplayBitmapTask(Bitmap bitmap, ImageLoadingInfo imageLoadingInfo, ImageLoaderEngine engine,LoadedFrom loadedFrom) {this.bitmap = bitmap;imageUri = imageLoadingInfo.uri;imageAware = imageLoadingInfo.imageAware;memoryCacheKey = imageLoadingInfo.memoryCacheKey;displayer = imageLoadingInfo.options.getDisplayer();listener = imageLoadingInfo.listener;this.engine = engine;this.loadedFrom = loadedFrom;}@Overridepublic void run() {if (imageAware.isCollected()) {//判断图片View是否已经被回收了,如果已经被回收,则取消任务L.d(LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED, memoryCacheKey);listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());} else if (isViewWasReused()) {//图片View是否又用来展示其他图片了,如果是的话,则取消任务L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, memoryCacheKey);listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());} else {L.d(LOG_DISPLAY_IMAGE_IN_IMAGEAWARE, loadedFrom, memoryCacheKey);displayer.display(bitmap, imageAware, loadedFrom);engine.cancelDisplayTaskFor(imageAware);listener.onLoadingComplete(imageUri, imageAware.getWrappedView(), bitmap);}}/** Checks whether memory cache key (image URI) for current ImageAware is actual */private boolean isViewWasReused() {//判断View是否又用来展示其他图片了。此处要思考理解一下String currentCacheKey = engine.getLoadingUriForView(imageAware);return !memoryCacheKey.equals(currentCacheKey);}}
0 0
- Universal-Image-Loader源码阅读(36)-DisplayBitmapTask
- Universal-Image-Loader源码阅读(35)-
- Universal-Image-Loader源码阅读(36)-LoadAndDisplayImageTask
- 【Android框架】Android-universal-image-loader源码阅读(一)
- Universal-Image-Loader源码阅读(1)-开篇
- Universal-Image-Loader源码阅读(2)-utils/L
- Universal-Image-Loader源码阅读(3)-utils/IoUtils
- Universal-Image-Loader源码阅读(4)-utils/ImageSizeUtils
- Universal-Image-Loader源码阅读(5)-core/iamgeaware/ImageAware
- Universal-Image-Loader源码阅读(6)-core/imageaware/ViewAware
- Universal-Image-Loader源码阅读(7)-core/imageaware/ImageViewAware
- Universal-Image-Loader源码阅读(8)-core/imageaware/NonViewAware
- Universal-Image-Loader源码阅读(9)-utils/StorageUtils
- Universal-Image-Loader源码阅读(10)-utils/MemoryCacheUtils
- Universal-Image-loader源码阅读(11)-catche/MemoryCache
- Universal-Image-Loader源码阅读(12)-cache/BaseMemoryCache
- Universal-Image-Loader源码阅读(13)-cache/LimitedMemoryCache
- Universal-Image-Loader源码阅读(14)-memory/impl/WeakMemoryCache
- 开播啦
- Linux内存描述之高端内存--Linux内存管理(五)
- 104 Maximum Depth of Binary Tree
- 断点
- Java中的位运算
- Universal-Image-Loader源码阅读(36)-DisplayBitmapTask
- 开播啦
- Spark四大组件包括Spark Streaming、Spark SQL、Spark MLlib和Spark GraphX。
- Scala变量
- 写在前面的话
- CoreText(二):段落CTParagraphStyle
- HashMap vs. TreeMap vs. Hashtable vs. LinkedHashMap
- 远程仓库
- 解决华为USG2110-F防火墙PPTP无法穿透,无法连接VPN