mirror of
https://gitee.com/shuto/cordova-imagePicker.git
synced 2026-05-05 00:00:01 +08:00
Merge pull request #24 from DATAWERK/image_listing_oom
Out of memory exception on image listing
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user