picasso总结

时间:2021-09-07 20:21:27
 public class UMDocApplication extends Application {
     private Picasso picasso = null;
     /**获取Picasso对象**/
     public Picasso getPicasso(){
         if(picasso == null)
             cancelPicassoCache();
         return picasso;
     }
     /**清除缓存并创建对象**/
     public void cancelPicassoCache(){
         if(picasso != null)
             picasso = null;
         LruCache lruCache = new LruCache(getApplicationContext());
         lruCache.clear();
         Picasso.Builder builder = new           Picasso.Builder(getApplicationContext()).memoryCache(lruCache);
         lruCache.clear();
         picasso = builder.build();
     }
 }
 if (UMDocApplication.getInstance().head != null) {
             UMDocApplication.getInstance().getPicasso()
                     .load(UMDocApplication.getInstance().head).into(img_head);
         }

Picasso不是很好用,个人觉得它唯一的优点就是加载图片用到的代码量很少,很方便,一开始我就是因为这个原因用它的,不过到了后来觉得问题还是不少的,当然,那是在特殊的情况下,比如你的图片地址是不变的,图片源一直在改变,那么Picasso就蒙蔽了,后来改成ImageLoader差距一下子就出现了,本文仅供自己记录学习,有说错的或则更好的见解欢迎告知评论