Fix crash on Android 2.3 caused by missing method

Bug: 49716

Change-Id: I34d34fbefc98a943d55dc6beb6c116f0f7f5e29c
GitHub: https://github.com/wikimedia/apps-android-commons/pull/16
This commit is contained in:
YuviPanda 2013-06-18 14:38:42 +00:00 committed by SuchABot
parent 052439a2d5
commit 1f61f310e1

View file

@ -121,9 +121,16 @@ public class CommonsApplication extends Application {
private LruCache<String, Bitmap> imageCache = new LruCache<String, Bitmap>((int) (Runtime.getRuntime().maxMemory() / (1024 * 8))) {
@Override
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
// number of items.
return bitmap.getByteCount() / 1024;
return bitmapSize / 1024;
}
};