picasso2.2.0下载 http://download.csdn.net/detail/dl6655/9393351
picasso2.5.2下载 http://download.csdn.net/detail/dl6655/9393353
原文件地址 http://blog.csdn.net/dl6655/article/details/50471176
名词解释
1、WeakhashMap ,SoftReferenceMap 用来存放可回收的对像
2、ReferenceQueue 引用插入队列,存放可回收对像的键值
http://my.oschina.net/sfshine/blog/219563
3、ExcutorService ,poolExcutorService线程池的启动关闭,维护,执行中,等待中,shutdown
shutdownNow
4、
类的差异
Picasso类 优化了单列的创建,增加了线程安全机制
2.5.2
public static void setSingletonInstance(Picasso picasso) {
Class var1 = Picasso.class;
synchronized(Picasso.class) {
if(singleton != null) {
throw new IllegalStateException("Singleton instance already exists.");
} else {
singleton = picasso;
}
}
}
2.2.0
public static Picasso with(Context context) {
if(singleton == null) {
singleton = (new Picasso.Builder(context)).build();
}
return singleton;
}
增加了Handler单独处理各个缓存的分发从Sdcard,数据库,Asset,File,netWork处的细分,还有Dispatcher的开始停止功能
Action类 新增了内存安全和网络安全变量的赋值
Utils类 里新增了当内存泄漏的时候刷新内存的方法
static void flushStackLocalLeaks(final Looper looper) {
Handler handler = new Handler(looper) {
public void handleMessage(Message msg) {
this.sendMessageDelayed(this.obtainMessage(), 1000L);
}
};
handler.sendMessageDelayed(handler.obtainMessage(), 1000L);
}
LruCache类 里面增加了清除指定URI的键值的缓存
public final synchronized void clearKeyUri(String uri) {
boolean sizeChanged = false;
int uriLength = uri.length();
Iterator i = this.map.entrySet().iterator();
while(i.hasNext()) {
Entry entry = (Entry)i.next();
String key = (String)entry.getKey();
Bitmap value = (Bitmap)entry.getValue();
int newlineIndex = key.indexOf(10);
if(newlineIndex == uriLength && key.substring(0, newlineIndex).equals
(uri)) {
i.remove();
this.size -= Utils.getBitmapBytes(value);
sizeChanged = true;
}
}
if(sizeChanged) {
this.trimToSize(this.maxSize);
}
}
BitmapHunter类 (对图片进行处理的类)
2.5.2使用了等比压缩,加载压缩后的图片,节省了一些内存
2.2直接全尺寸加载没有进行任何的压缩处理,比较耗内存
Dispatcher类 增加了错误日制功能.