Merge pull request #24 from DATAWERK/image_listing_oom

Out of memory exception on image listing
This commit is contained in:
CSullivan102
2014-09-04 09:42:43 -04:00
+30 -25
View File
@@ -178,29 +178,34 @@ public class ImageFetcher {
*/
@Override
protected Bitmap doInBackground(Integer... params) {
position = params[0];
if (isCancelled()) {
return null;
}
Bitmap thumb = MediaStore.Images.Thumbnails.getThumbnail(mContext.getContentResolver(), position, 12345,
MediaStore.Images.Thumbnails.MINI_KIND, null);
if (isCancelled()) {
return null;
}
if (thumb == null) {
return null;
} else {
if (isCancelled()) {
return null;
} else {
if (rotate != 0) {
Matrix matrix = new Matrix();
matrix.setRotate(rotate);
thumb = Bitmap.createBitmap(thumb, 0, 0, thumb.getWidth(), thumb.getHeight(), matrix, true);
}
return thumb;
}
}
try {
position = params[0];
if (isCancelled()) {
return null;
}
Bitmap thumb = MediaStore.Images.Thumbnails.getThumbnail(mContext.getContentResolver(), position, 12345,
MediaStore.Images.Thumbnails.MINI_KIND, null);
if (isCancelled()) {
return null;
}
if (thumb == null) {
return null;
} else {
if (isCancelled()) {
return null;
} else {
if (rotate != 0) {
Matrix matrix = new Matrix();
matrix.setRotate(rotate);
thumb = Bitmap.createBitmap(thumb, 0, 0, thumb.getWidth(), thumb.getHeight(), matrix, true);
}
return thumb;
}
}
}catch(OutOfMemoryError error) {
clearCache();
return null;
}
}
@@ -362,8 +367,8 @@ public class ImageFetcher {
* after a certain inactivity delay.
*/
public void clearCache() {
// sHardBitmapCache.clear();
// sSoftBitmapCache.clear();
sHardBitmapCache.clear();
sSoftBitmapCache.clear();
}
/**