Example usage for android.support.v4.util LruCache LruCache

List of usage examples for android.support.v4.util LruCache LruCache

Introduction

In this page you can find the example usage for android.support.v4.util LruCache LruCache.

Prototype

public LruCache(int maxSize) 

Source Link

Usage

From source file:inujini_.hatate.volley.BitmapCache.java

public BitmapCache() {
    int maxSize = 1 * 1024 * 1024;
    _cache = new LruCache<String, Bitmap>(maxSize) {
        @Override//from   w ww  .jav  a  2  s  .com
        protected int sizeOf(String key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();
        }
    };
}

From source file:com.binkery.app.filemanager.fragments.ThumbnailLoader.java

public static ThumbnailLoader getInstance(Context context) {
    if (mLoader == null) {
        mLoader = new ThumbnailLoader();
        mLoader.mContext = context;/* www. j  a  va 2 s .c  om*/
        final int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE))
                .getMemoryClass();

        // Use 1/8th of the available memory for this memory cache.
        final int cacheSize = 1024 * 1024 * memClass / 8;
        mLoader.mCache = new LruCache<String, Bitmap>(cacheSize);
        mLoader.mTaskList = new ArrayList<ThumbnailLoader.TaskItem>();
    }
    return mLoader;
}

From source file:org.mozilla.gecko.util.NonEvictingLruCache.java

public NonEvictingLruCache(final int evictableSize) {
    evictable = new LruCache<K, V>(evictableSize);
}

From source file:com.fenlisproject.elf.core.data.MemoryStorage.java

public MemoryStorage(int maxSize) {
    cache = new LruCache<>(maxSize);
}

From source file:org.montanafoodhub.app.utils.ImageCache.java

public ImageCache() {

    // set the cache to be 1/8 of the total memory (kilobytes)
    int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    int cacheSize = maxMemory / 8;

    Log.w(LogTag, "Cache Size: " + cacheSize);

    _cache = new LruCache<String, Bitmap>(cacheSize) {
        @Override/*from  w w  w .  ja v  a2s  . c  o  m*/
        protected int sizeOf(String key, Bitmap bitmap) {
            // todo bitmap.getAllocationByteCount()
            return (bitmap.getRowBytes() * bitmap.getHeight()) / 1024;
        }
    };
}

From source file:com.teegarcs.mocker.internals.MockerCacheManager.java

public MockerCacheManager() {
    mockerDockCache = new LruCache<>(MAX_DATA_SIZE);

}

From source file:com.xxjwd.chat.util.ImageCache.java

 private ImageCache() {
   // use 1/8 of available heap size
   cache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / 8)) {
           @Override/*from   w  w w  . j a v a  2  s .c  o m*/
           protected int sizeOf(String key, Bitmap value) {
               return value.getRowBytes() * value.getHeight();
           }
       };
}

From source file:com.safeness.im.utils.ImageCache8.java

private ImageCache8() {
    // use 1/8 of available heap size
    cache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / 8)) {
        @Override//from   ww w  . java2 s  . c o m
        protected int sizeOf(String key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();
        }
    };
}

From source file:cn.xcom.helper.chat.easeui.model.EaseImageCache.java

private EaseImageCache() {
    // use 1/8 of available heap size
    cache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / 8)) {
        @Override/*from   w w w.ja v a  2s.c o  m*/
        protected int sizeOf(String key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();
        }
    };
}

From source file:cmu.cconfs.instantMessage.utils.ImageCache.java

private ImageCache() {
    // use 1/8 of available heap size
    cache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / 8)) {
        @Override//from   w w  w.j  ava  2 s .  co m
        protected int sizeOf(String key, Bitmap value) {
            return value.getRowBytes() * value.getHeight();
        }
    };
}