List of usage examples for android.support.v4.util LruCache LruCache
public LruCache(int maxSize)
From source file:com.example.android.leanback.PlaybackSeekAsyncDataProvider.java
public PlaybackSeekAsyncDataProvider(int cacheSize, int prefetchCacheSize) { mCache = new LruCache<Integer, Bitmap>(cacheSize); mPrefetchCache = new LruCache<Integer, Bitmap>(prefetchCacheSize); }
From source file:com.sqkj.engine.image.ImageCache.java
private void init(ImageCacheParams cacheParams) { mCacheParams = cacheParams;//from w ww . ja v a2 s .c o m if (mCacheParams.memoryCacheEnabled) { WaterDropsLog.v("Memory cache created (size = " + mCacheParams.memCacheSize + ")"); if (SdkUtils.hasHoneycomb()) { mReusableBitmaps = Collections.synchronizedSet(new HashSet<SoftReference<Bitmap>>()); } mMemoryCache = new LruCache<String, BitmapDrawable>(mCacheParams.memCacheSize) { @Override protected void entryRemoved(boolean evicted, String key, BitmapDrawable oldValue, BitmapDrawable newValue) { if (RecyclingBitmapDrawable.class.isInstance(oldValue)) { ((RecyclingBitmapDrawable) oldValue).setIsCached(false); } else { if (SdkUtils.hasHoneycomb()) { mReusableBitmaps.add(new SoftReference<Bitmap>(oldValue.getBitmap())); } } } @Override protected int sizeOf(String key, BitmapDrawable value) { final int bitmapSize = getBitmapSize(value) / 1024; WaterDropsLog.d("@@@@@@Bitmap Size==>" + bitmapSize); return bitmapSize == 0 ? 1 : bitmapSize; } }; } }
From source file:parent.com.parentphone.util.ImageCache.java
/** * Initialize the cache./*from w ww . j a v a 2 s . c o m*/ * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private void init(float memCacheSizePercent) { int memCacheSize = calculateMemCacheSize(memCacheSizePercent); mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { /** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:com.epishie.tabs.feature.shared.repository.RetrofitRedditRepository.java
public RetrofitRedditRepository(String baseUrl, TokenManager tokenManager) { HttpLoggingInterceptor logger = new HttpLoggingInterceptor(); logger.setLevel(HttpLoggingInterceptor.Level.BASIC); OkHttpClient client = new OkHttpClient.Builder().addInterceptor(logger) .addInterceptor(tokenManager.getInterceptor()).addInterceptor(mDecorator).build(); Gson gson = new GsonBuilder().registerTypeAdapter(Thing.class, new ThingDeserializer()).create(); Retrofit retrofit = new Retrofit.Builder().baseUrl(baseUrl).client(client) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create(gson)) .addConverterFactory(ScalarsConverterFactory.create()).build(); mService = retrofit.create(Service.class); mSubredditsCache = new LruCache<>(5000 * 1024); mLinksCache = new LruCache<>(5000 * 1024); mLinkCache = new LruCache<>(5000 * 1024); }
From source file:com.radar.niyo.contacts.ImageCache.java
/** * Initialize the cache.//from w ww. j av a 2 s .c o m * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private void init(float memCacheSizePercent) { int memCacheSize = calculateMemCacheSize(memCacheSizePercent); // Set up memory cache // if (BuildConfig.DEBUG) { Log.d(TAG, "Memory cache created (size = " + memCacheSize + ")"); // } mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { /** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:com.githang.androidkit.cache.BitmapLruCache.java
/** * ?/*from w w w . j av a2s . c om*/ */ private void initCache() { if (mParams.isMemCacheEnabled()) { if (BuildConfig.DEBUG) { log.d("Memory cache created (size = " + mParams.getMemCacheSize() + "B)"); } mMemoryCache = new LruCache<String, Bitmap>(mParams.getMemCacheSize()) { @Override protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); } }; } // Set up disk cache initDiskCache(); }
From source file:android.com.example.contactslist.util.ImageCache.java
/** * Initialize the cache.//w w w . j ava 2 s . c o m * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private void init(float memCacheSizePercent) { int memCacheSize = calculateMemCacheSize(memCacheSizePercent); // Set up memory cache if (BuildConfig.DEBUG) { Log.d(TAG, "Memory cache created (size = " + memCacheSize + ")"); } mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { /** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:fr.jbteam.jabboid.core.ImageCache.java
/** * Initialize the cache./*from www . ja v a 2s . c o m*/ * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private void init(float memCacheSizePercent) { int memCacheSize = calculateMemCacheSize(memCacheSizePercent); // Set up memory cache /* if (BuildConfig.DEBUG) { Log.d(TAG, "Memory cache created (size = " + memCacheSize + ")"); }*/ mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { /** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:learn2crack.utilities.ImageCache.java
/** * Initialize the cache./*from w w w .jav a 2 s . co m*/ * * @param memCacheSizePercent The cache size as a percent of available app memory. */ private void init(float memCacheSizePercent) { int memCacheSize = calculateMemCacheSize(memCacheSizePercent); // Set up memory cache //if (BuildConfig.DEBUG) { // Log.d(TAG, "Memory cache created (size = " + memCacheSize + ")"); //} mMemoryCache = new LruCache<String, Bitmap>(memCacheSize) { /** * Measure item size in kilobytes rather than units which is more practical * for a bitmap cache */ @Override protected int sizeOf(String key, Bitmap bitmap) { final int bitmapSize = getBitmapSize(bitmap) / 1024; return bitmapSize == 0 ? 1 : bitmapSize; } }; }
From source file:id.wibisana.priadimulia.imagecaching.cache.ImageCache.java
private void init(ImageCacheParams cacheParams) { mCacheParams = cacheParams;//ww w.ja v a 2 s . co m if (mCacheParams.memoryCacheEnabled) { mMemoryCache = new LruCache<String, Bitmap>(mCacheParams.memCacheSize) { @Override protected int sizeOf(String key, Bitmap bitmap) { return getBitmapSize(bitmap); } }; } if (cacheParams.initDiskCacheOnCreate) { initDiskCache(); } }