Android 圖片三級快取
阿新 • • 發佈:2019-03-26
public class MemoryCache {
private LruCache<String, Bitmap> lruCache;
public MemoryCache() {
lruCache = new LruCache<String, Bitmap>((int)(Runtime.getRuntime().maxMemory()/8)) {
protected int sizeOf(String key, Bitmap bitmap) {
return bitmap.getByteCount();
}
}
}
public void put(String key, Bitmap bitmap) {
lruCache.put(key, bitmap);
}
public Bitmap get(String key) {
lruCache.get(key);
&n