Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25540] Android: Fix sizeOf() calculation to prevent IllegalStateException #9620

Merged
merged 7 commits into from
Jan 4, 2018
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,8 @@ public TiBlobLruCache()
@Override
protected int sizeOf(String key, Bitmap bitmap)
{
// The cache size will be measured in kilobytes rather than
// number of items.
if (android.os.Build.VERSION.SDK_INT > TiC.API_LEVEL_HONEYCOMB) {
return bitmap.getByteCount() / 1024;
} else {
return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
}
int byteCount = bitmap.getRowBytes() * bitmap.getHeight();
return byteCount / 1024;
}

public void addBitmapToMemoryCache(String key, Bitmap bitmap) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ public TiImageLruCache()
@Override
protected int sizeOf(Integer key, Bitmap bitmap)
{
// The cache size will be measured in kilobytes rather than
// number of items.
if (android.os.Build.VERSION.SDK_INT > TiC.API_LEVEL_HONEYCOMB) {
return bitmap.getByteCount() / 1024;
} else {
return bitmap.getRowBytes() * bitmap.getHeight() / 1024;
}
int byteCount = bitmap.getRowBytes() * bitmap.getHeight();
return byteCount / 1024;
}
}