/** * @author gongchaobin * * LruCache缓存Bitmap * (基于内存的缓存,读取时间比较快) */public class LruCacheUtil { private static final String TAG = LruCacheUtil.class.getSimpleName(); private int memClass; private LruCachemMemoryCache;//高速缓存(系统) public static final String BITMAP = "bitmap"; public LruCacheUtil(Context context){ memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); final int cacheSize = 1024 * 1024 * memClass / 8; mMemoryCache = new LruCache (cacheSize); } public void addBitmapToMemoryCache(String key, Bitmap bitmap) { if (getBitmapFromMemCache(key) == null) { mMemoryCache.put(key, bitmap); } } public Bitmap getBitmapFromMemCache(String key) { return mMemoryCache.get(key); }}