android-UIL图片缓存框架 主要类包括的成员

UIL 框架  包括 ImageLoader、ImageLoaderConfiguration、ImageLoaderEngine 、ImageDownloader、ImageDecoder、DisplayImageOptions


首先是ImageLoader类  

private ImageLoaderConfiguration configuration;  //配置信息类
	private ImageLoaderEngine engine;   //图片加载引擎   用于开启图片加载任务的类  

	private ImageLoadingListener defaultListener = new SimpleImageLoadingListener();   //图片加载的监听类  

	private volatile static ImageLoader instance;   //单例模式的实例
这个类成员变量不多   包含了 displayImage  和 loadImage等加载图片的方法


ImageLoaderConfiguration类:

final Resources resources;

	final int maxImageWidthForMemoryCache;  //内存缓存的图片宽度最大值  默认为屏幕宽度
	final int maxImageHeightForMemoryCache;  //同上
	final int maxImageWidthForDiskCache;  //磁盘缓存宽度  默认无限制
	final int maxImageHeightForDiskCache;  //同上
	final BitmapProcessor processorForDiskCache;  //位图处理器  磁盘缓存 处理器

	final Executor taskExecutor;   //任务执行者
	final Executor taskExecutorForCachedImages;   //缓存图片任务执行者
	final boolean customExecutor;   //自定义的任务执行者
	final boolean customExecutorForCachedImages;   //自定义的缓存图片任务执行者

	final int threadPoolSize;   //线程池 大小  默认为3
	final int threadPriority;  //线程优先级
	final QueueProcessingType tasksProcessingType;   //队列的类型 可以选择 FIFO(先进先出)LIFO(后进先出)

	final MemoryCache memoryCache;   //内存缓存
	final DiskCache diskCache;   //磁盘缓存
	final ImageDownloader downloader;  //图片下载器
	final ImageDecoder decoder;    //图片解码器
	final DisplayImageOptions defaultDisplayImageOptions;  //图片展示选项

	final ImageDownloader networkDeniedDownloader;   //离线图片下载器
	final ImageDownloader slowNetworkDownloader;   //网速慢图片下载器

这个类用于在displayImage之前初始化配置信息  可以设置一些缓存的基本配置  

ImageLoaderEngine 类:

<span style="white-space:pre">	</span>final ImageLoaderConfiguration configuration;  //构造函数传递过来的配置信息   主要使用其中的 executor 

	private Executor taskExecutor;  //普通的任务执行者
	private Executor taskExecutorForCachedImages;  //需要缓存时的任务执行者
	private Executor taskDistributor;   //任务分配者

	private final Map<Integer, String> cacheKeysForImageAwares = Collections
			.synchronizedMap(new HashMap<Integer, String>());   //存放的缓存的ImageAwares的 key
	private final Map<String, ReentrantLock> uriLocks = new WeakHashMap<String, ReentrantLock>();

	private final AtomicBoolean paused = new AtomicBoolean(false);  //是否暂停
	private final AtomicBoolean networkDenied = new AtomicBoolean(false);  //是否无网络
	private final AtomicBoolean slowNetwork = new AtomicBoolean(false);   //是否 网络很慢

	private final Object pauseLock = new Object();  //暂停的锁
这个类中 还包含  submit方法  对于 图片的加载任务  一般都是从这个类的 submit 提交过来  然后调用 传入配置ImageLoaderConfiguration 类中的 executor类的execute方法 之后调用task 的run方法  进行的   

ImageDownloader类:

这个类主要提供 从网络下载图片的功能 包括以下几个 子类  简单来说就是封装了 http 请求 和接受返回信息 而已  


ImageDecoder类:

此类主要是把  流转化为bitmap图片  根据传入的 ImageDecodingInfo   也很简单 

	//ImageDecodingInfo中的成员:
<span style="white-space:pre">	</span>private final String imageKey;
	private final String imageUri;
	private final String originalImageUri;
	private final ImageSize targetSize;

	private final ImageScaleType imageScaleType;
	private final ViewScaleType viewScaleType;

	private final ImageDownloader downloader;
	private final Object extraForDownloader;

	private final boolean considerExifParams;
	private final Options decodingOptions;

DisplayImageOptions类:

显示图片时的 选项 可以配置图片加载时、uri空、加载失败时的图片 以及一些下述的变量


<span style="white-space:pre">	</span>private final int imageResOnLoading;  //正在加载时的资源id
	private final int imageResForEmptyUri;  //空的
	private final int imageResOnFail;  //失败的
	private final Drawable imageOnLoading;  
	private final Drawable imageForEmptyUri;
	private final Drawable imageOnFail;
	private final boolean resetViewBeforeLoading;
	private final boolean cacheInMemory;  //是否缓存在内存
	private final boolean cacheOnDisk;  //是否缓存在硬盘
	private final ImageScaleType imageScaleType;  //图像缩放类型
	private final Options decodingOptions;   //解码选项  
	private final int delayBeforeLoading;   //加载前的延时 
	private final boolean considerExifParams;  
	private final Object extraForDownloader;   
	private final BitmapProcessor preProcessor;  //之前的图像处理 
	private final BitmapProcessor postProcessor;  //之后的图像处理 
	private final BitmapDisplayer displayer;  //图像展示器
	private final Handler handler;   
	private final boolean isSyncLoading;  //是否同步加载中 





你可能感兴趣的:(android-UIL图片缓存框架 主要类包括的成员)