Picasso p = new Picasso.Builder(context) .memoryCache(new LruCache(24000)) .build();
.memoryCache(new LruCache(100000000)) // Maybe something fishy here?
int maxSize = MAX_CACHE_SIZE; Picasso picasso = new Picasso.Builder(context) .memoryCache(new LruCache(maxSize)) .build();
int maxSize = MAX_CACHE_SIZE; Picasso picasso = new Picasso.Builder(context) .memoryCache(new LruCache(maxSize)).build();
Picasso picasso = new Picasso.Builder(context) .memoryCache(new LruCache(250)) .build();
int cacheSize = 4 * 1024 * 1024; // 4MiB Picasso myNewPicasso = new Picasso.Builder(context).memoryCache(new LruCache(cacheSize)).build(); myNewPicasso.with(mcontext) .load(item.getUrl()) .placeholder(R.drawable.logo) .fit() .noFade() .into(holder.imageView);
var cache = new File(BaseContext.ApplicationContext.CacheDir, "picasso-cache"); if (!cache.Exists()) cache.Mkdirs(); _lruCache = new LruCache((int)Runtime.GetRuntime().MaxMemory() / 1024 * 8); _diskLruCache = new DiskLruCache(cache, 10 * 1024 * 1024); _picasso = new Picasso.Builder(BaseContext).MemoryCache(_lruCache).Downloader(new OkHttpDownloader(_OkHttp3Client)).IndicatorsEnabled(true).Build();
// uses 1/8th of the memory for the cache final int cacheSize = (int) (Runtime.getRuntime().maxMemory() / 8L); LruCache bitmapCache = new LruCache(cacheSize) { protected int sizeOf(String key, Bitmap value) { return value.getByteCount(); }}
int cacheSize = 4 * 1024 * 1024; // 4MiB LruCache bitmapCache = new LruCache(cacheSize) { protected int sizeOf(String key, Bitmap value) { return value.getByteCount(); } } synchronized (cache) { if (cache.get(key) == null) { cache.put(key, value); } }
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);
Picasso.Builder builder = new Picasso.Builder(this); LruCache picassoCache = new LruCache(this); builder.memoryCache(picassoCache); Picasso.setSingletonInstance(builder.build());
/** 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; }
protected void createReadyStore(int cacheSize, int numberOfVictimsToSelect, float loadFactor, long idleTimeout) throws Exception { idleTimeout = (idleTimeout <= 0) ? -1 : idleTimeout; if (cacheSize <= 0 && idleTimeout <= 0) { readyStore = new BaseCache(); cacheSize = DEFAULT_CACHE_SIZE; readyStore.init(cacheSize, loadFactor, null); } else { cacheSize = (cacheSize <= 0) ? DEFAULT_CACHE_SIZE : cacheSize; LruCache lru = new LruCache(DEFAULT_CACHE_SIZE); if (numberOfVictimsToSelect >= 0) { loadFactor = (float) (1.0 - (1.0 * numberOfVictimsToSelect/cacheSize)); } lru.init(cacheSize, idleTimeout, loadFactor, null); readyStore = lru; readyStore.addCacheListener(this); } if (idleTimeout > 0) { idleBeansPassivator = setupIdleBeansPassivator(readyStore); } }