Skip to content

Commit

Permalink
Merge pull request #9620 from garymathews/TIMOB-25540
Browse files Browse the repository at this point in the history
[TIMOB-25540] Android: Fix sizeOf() calculation to prevent IllegalStateException
  • Loading branch information
ssjsamir committed Jan 4, 2018
2 parents 1549847 + 9d70b04 commit 158d75e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
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;
}
}

0 comments on commit 158d75e

Please sign in to comment.