List of usage examples for android.support.v4.util LruCache LruCache
public LruCache(int maxSize)
From source file:com.mabi87.imageloader.ImageMemoryCache.java
private ImageMemoryCache() { mCache = new LruCache<String, Bitmap>(cacheSize) { @Override//from w w w. ja v a 2s.co m protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getByteCount() / 1024; } }; }
From source file:com.arthurpitman.common.data.LocalProvider.java
/** * Creates a LocalProvider with the specified cache size. * @param cacheSize/* ww w . j a v a 2 s . c om*/ */ public LocalProvider(int cacheSize) { cache = new LruCache<Long, T>(cacheSize); }
From source file:info.wncwaterfalls.app.grid.MemoryCache.java
public MemoryCache() { mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override/*from w w w.j a va 2 s .c om*/ protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in kilobytes rather than // number of items. return getByteCount(bitmap) / 1024; } }; }
From source file:com.tz.explore.util.ImageLoader.java
private ImageLoader() { TaskPoster.initPoster();//from ww w . ja va 2 s.co m int maxSize = (int) (Runtime.getRuntime().maxMemory() / 8); cache = new LruCache<String, Bitmap>(maxSize) { @Override protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight() / 1024; } }; }
From source file:gr.scify.newsum.controllers.CacheController.java
private static LruCache<String, Object> createCache() { // set cache clearance cacheTimer.purge();//from w w w. ja v a 2s . com cacheTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { clearCache(); } }, EXPIRATION, EXPIRATION); // create cache return new LruCache<String, Object>((int) (Runtime.getRuntime().maxMemory() / 3)); }
From source file:com.google.android.apps.santatracker.util.LruImageCache.java
public LruImageCache() { // Naive calculation of available memory: Use 1/8th of memory for cache int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); int cacheSize = maxMemory / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override// w w w.j a va2 s.com protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getByteCount() / 1024; } }; }
From source file:com.busdrone.android.ui.VehicleMarkerRenderer.java
public VehicleMarkerRenderer(Context context) { mCache = new LruCache<String, Bitmap>(Utils.calculateMemoryCacheSize(context)); mCornerRadius = context.getResources().getDimensionPixelOffset(R.dimen.marker_radius); mTextSize = context.getResources().getDimensionPixelSize(R.dimen.marker_text_size); mPadding = context.getResources().getDimensionPixelOffset(R.dimen.marker_padding); }
From source file:com.evandroid.musica.utils.CoverCache.java
private CoverCache() { // Get the Max available memory int maxMemory = (int) Runtime.getRuntime().maxMemory(); int cacheSize = maxMemory / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override//from w w w. j ava 2s . c om protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); } }; }
From source file:org.jitsi.android.gui.util.DrawableCache.java
/** * Creates new instance of <tt>DrawableCache</tt>. *//*from w ww. ja v a 2 s .c o m*/ public DrawableCache() { // Get max available VM memory, exceeding this amount will throw an // OutOfMemory exception. Stored in kilobytes as LruCache takes an // int in its constructor. final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); // Use 1/8th of the available memory for this memory cache. final int cacheSize = maxMemory / 8; cache = new LruCache<String, BitmapDrawable>(cacheSize) { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override protected int sizeOf(String key, BitmapDrawable value) { Bitmap bmp = value.getBitmap(); int byteSize; if (AndroidUtils.hasAPI(Build.VERSION_CODES.HONEYCOMB_MR1)) { byteSize = bmp.getByteCount(); } else { byteSize = bmp.getRowBytes() * bmp.getHeight(); } return byteSize / 1024; } }; }
From source file:com.extradea.framework.images.cache.LruBitmapCache.java
public LruBitmapCache(int size) { imageTempCache = new HashMap<String, WeakReference<Bitmap>>(); imageCache = new LruCache<String, Bitmap>(size) { @Override/*w w w .jav a 2 s . c om*/ protected int sizeOf(String key, Bitmap value) { if (Build.VERSION.SDK_INT >= 12) { return value.getByteCount(); } else { return value.getRowBytes() * value.getHeight(); } } }; }