final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); // Use 1/8th of the available memory for this memory cache. final int cacheSize = maxMemory / 8; Picasso.Builder builder = new Picasso.Builder(getApplicationContext()); builder.memoryCache(new LruCache(cacheSize)); Picasso built = builder.build(); built.setIndicatorsEnabled(true);// it will show indicator where it downloaded from built.setLoggingEnabled(false); Picasso.setSingletonInstance(built);
/** Other Initialization **/ private LruCache mCache; private Picasso mPicasso; private void setupImageManager() { Picasso.Builder builder = new Picasso.Builder(this); mCache = new LruCache(this); builder.memoryCache(mCache); mPicasso = builder.build(); } public Picasso getPicasso() { return mPicasso; }
public static Picasso getPicasso(Context context) { if (sPicasso == null) { sPicasso = new Picasso.Builder(context) //硬盘缓存池大小 .downloader(new OkHttpDownloader(context, ConfigConstants.MAX_CACHE_DISK_SIZE)) //内存缓存池大小 .memoryCache(new LruCache(ConfigConstants.MAX_CACHE_MEMORY_SIZE)) // .defaultBitmapConfig(Bitmap.Config.ARGB_4444) .build(); } return sPicasso; } }
private static Picasso getPicasso() { if (sPicassoSingleton == null) { synchronized (PicassoLoader.class) { if (sPicassoSingleton == null) { sPicassoSingleton = new Picasso.Builder(App.gApp).memoryCache(sLruCache).build(); } } } return sPicassoSingleton; }
Picasso.Builder builder = new Picasso.Builder(this); LruCache picassoCache = new LruCache(this); builder.memoryCache(picassoCache); Picasso.setSingletonInstance(builder.build());