List of usage examples for android.support.v4.util LruCache LruCache
public LruCache(int maxSize)
From source file:com.lark.http.cache.BitmapImageCache.java
private void init(int memCacheSize) { mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { @Override/* w ww . j a v a 2 s. c o m*/ protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } @Override protected void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) { super.entryRemoved(evicted, key, oldValue, newValue); } }; }
From source file:com.hellosky.recyclingimageloader.util.ImageMemoryCache.java
public ImageMemoryCache() { setLimit(Math.round(0.15f * Runtime.getRuntime().maxMemory() / 1024)); mMemoryCache = new LruCache<String, BitmapDrawable>(limit) { /**//from w w w.j ava 2s .c o m * Notify the removed entry that is no longer being cached */ @Override protected void entryRemoved(boolean evicted, String key, BitmapDrawable oldValue, BitmapDrawable newValue) { if (RecyclingBitmapDrawable.class.isInstance(oldValue)) { // The removed entry is a recycling drawable, so notify it // that it has been removed from the memory cache ((RecyclingBitmapDrawable) oldValue).setIsCached(false); } } /** * Measure item size in kilobytes rather than units which is more * practical for a bitmap cache */ @Override protected int sizeOf(String key, BitmapDrawable value) { final int bitmapSize = getBitmapSize(value) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:it.michelepiccirillo.paperplane.client.Picture.java
public static void setCacheSize(int cacheSize) { Picture.cacheSize = cacheSize;/*ww w . j av a2 s . c o m*/ cache = new LruCache<Long, Bitmap>(cacheSize) { protected int sizeOf(Long key, Bitmap value) { return value.getByteCount(); }; }; }
From source file:com.google.firebase.linelogindemo.util.NetworkSingleton.java
private NetworkSingleton(Context context) { mCtx = context;//from w ww .j a v a 2 s . c o m mRequestQueue = getRequestQueue(); mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() { private final LruCache<String, Bitmap> cache = new LruCache<String, Bitmap>(20); @Override public Bitmap getBitmap(String url) { return cache.get(url); } @Override public void putBitmap(String url, Bitmap bitmap) { cache.put(url, bitmap); } }); }
From source file:com.stargame.ad.util.cache.image.AbImageBaseCache.java
/** * ./*from w w w.j av a 2 s. c o m*/ */ public AbImageBaseCache() { super(); int maxSize = AppConfig.MAX_CACHE_SIZE_INBYTES; mCache = new LruCache<String, Bitmap>(maxSize) { @Override protected int sizeOf(String key, Bitmap value) { try { return value.getRowBytes() * value.getHeight(); } catch (Exception e) { // e.printStackTrace(); return value.getByteCount(); } } }; }
From source file:com.instagram.igdiskcache.demo.cache.BitmapCache.java
public BitmapCache(Context context) { mContext = context; mMemoryCache = new LruCache<>(DEFAULT_MEM_CACHE_CAP); }
From source file:com.arthurpitman.common.data.RemoteProvider.java
/** * Creates a new RemoteProvider with the specified cache size. * @param cacheSize/*from ww w. j a va 2s . co m*/ */ public RemoteProvider(int cacheSize) { cache = new LruCache<Long, T>(cacheSize); }
From source file:com.madgag.agit.filepath.CachingFilePathListMatcher.java
public CachingFilePathListMatcher(final List<FilePath> filePaths) { filteredPathsCache = new LruCache<String, List<FilePath>>(32) { @Override/* www . j ava 2 s. c om*/ protected List<FilePath> create(String key) { List<FilePath> searchSpace; if (key.length() > 1) { searchSpace = filteredPathsCache.get(key.substring(0, key.length() - 1)); } else { searchSpace = filePaths; } return newArrayList(filter(searchSpace, new FilePathMatcher(key))); } }; sortedPathsCache = new LruCache<String, List<FilePath>>(16) { @Override protected List<FilePath> create(String key) { Iterable<FilePath> filteredPaths = filteredPathsCache.get(key); return Lists.transform(ScoredPath.ORDERING.sortedCopy(transform(filteredPaths, scoreFor(key))), ScoredPath.PATH); } }; }
From source file:com.oprisnik.semdroid.results.SemdroidReportCache.java
private SemdroidReportCache(int maxSize) { mMemoryCache = new LruCache<String, LiteSemdroidReport>(maxSize); }
From source file:org.geometerplus.android.util.BitmapCache.java
public BitmapCache(float factor) { myLruCache = new LruCache<Long, Container>((int) (factor * Runtime.getRuntime().maxMemory())) { @Override//from w w w . j av a2 s . co m protected int sizeOf(Long key, Container container) { return container.size(); } }; }