你的位置:首页 > 操作系统

[操作系统]picasso总结


 1 public class UMDocApplication extends Application { 2   private Picasso picasso = null; 3   /**获取Picasso对象**/ 4   public Picasso getPicasso(){ 5     if(picasso == null) 6       cancelPicassoCache(); 7     return picasso; 8   } 9   /**清除缓存并创建对象**/10   public void cancelPicassoCache(){11     if(picasso != null)12       picasso = null;13     LruCache lruCache = new LruCache(getApplicationContext());14     lruCache.clear();15     Picasso.Builder builder = new      Picasso.Builder(getApplicationContext()).memoryCache(lruCache);16     lruCache.clear();17     picasso = builder.build();18   }19 }

1 if (UMDocApplication.getInstance().head != null) {2       UMDocApplication.getInstance().getPicasso()3           .load(UMDocApplication.getInstance().head).into(img_head);4     }