Back to project page karin.
The source code is released under:
MIT License
If you think the Android project karin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package cc.wanko.karin.app.utils; //from w w w .j a v a 2 s. c o m import android.graphics.Bitmap; import android.support.v4.util.LruCache; import com.android.volley.toolbox.ImageLoader; /** * Created by eagletmt on 14/04/30. */ public class LruImageCache implements ImageLoader.ImageCache { private final LruCache<String, Bitmap> cache; public LruImageCache() { cache = new LruCache<String, Bitmap>(cacheSize()) { @Override protected int sizeOf(String key, Bitmap value) { return value.getRowBytes() * value.getHeight(); } }; } private static int cacheSize() { return (int) (Runtime.getRuntime().maxMemory() / 8); } @Override public Bitmap getBitmap(String key) { return cache.get(key); } @Override public void putBitmap(String key, Bitmap bitmap) { cache.put(key, bitmap); } }