Created
March 26, 2013 08:37
-
-
Save duanhong169/5243929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private LruCache<String, BitmapDrawable> mMemoryCache; | |
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); | |
// 使用最大可使用内存的1/8作为缓存 | |
final int cacheSize = maxMemory / 8; | |
mMemoryCache = new LruCache<String, BitmapDrawable>(cacheSize) { | |
/** | |
* 衡量某个bitmap大小的方法 | |
*/ | |
@Override | |
protected int sizeOf(String key, BitmapDrawable value) { | |
final int bitmapSize = getBitmapSize(value) / 1024; | |
return bitmapSize == 0 ? 1 : bitmapSize; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment