mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge "Fix crash on Android 2.3 caused by missing method"
This commit is contained in:
commit
e05053933d
1 changed files with 8 additions and 1 deletions
|
|
@ -121,9 +121,16 @@ public class CommonsApplication extends Application {
|
||||||
private LruCache<String, Bitmap> imageCache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / (1024 * 8))) {
|
private LruCache<String, Bitmap> imageCache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / (1024 * 8))) {
|
||||||
@Override
|
@Override
|
||||||
protected int sizeOf(String key, Bitmap bitmap) {
|
protected int sizeOf(String key, Bitmap bitmap) {
|
||||||
|
// bitmap.getByteCount() not available on older androids
|
||||||
|
int bitmapSize;
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
|
||||||
|
bitmapSize = bitmap.getRowBytes() * bitmap.getHeight();
|
||||||
|
} else {
|
||||||
|
bitmapSize = bitmap.getByteCount();
|
||||||
|
}
|
||||||
// The cache size will be measured in kilobytes rather than
|
// The cache size will be measured in kilobytes rather than
|
||||||
// number of items.
|
// number of items.
|
||||||
return bitmap.getByteCount() / 1024;
|
return bitmapSize / 1024;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue