diff options
author | kaiyiz <kaiyiz@codeaurora.org> | 2013-08-16 10:00:11 +0800 |
---|---|---|
committer | emancebo <emancebo@cyngn.com> | 2014-09-04 10:40:16 -0700 |
commit | e78bf0d1427d0d5a089d44f87e0aa9906bbf5c87 (patch) | |
tree | 226086d3128174b9a4ce09ba6e096d7f2d509458 /src | |
parent | 8599491de1b8c4c89f19a1958c5a2d6408b06d4c (diff) | |
download | android_packages_apps_Gallery2-e78bf0d1427d0d5a089d44f87e0aa9906bbf5c87.tar.gz android_packages_apps_Gallery2-e78bf0d1427d0d5a089d44f87e0aa9906bbf5c87.tar.bz2 android_packages_apps_Gallery2-e78bf0d1427d0d5a089d44f87e0aa9906bbf5c87.zip |
Gallery2: catch OOM error when crop big-size picture
An OOM error happened when set big size of picture as wallpaper
We catch the OOM error, and if fail to crop the picture, we
show a toast.
CRs-Fixed: 522476
Change-Id: Ia9d7f41ca768c9183b26051fb08c9f823fec0074
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/filtershow/crop/CropActivity.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java index 3a7829681..9a0167a4f 100644 --- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java +++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java @@ -347,6 +347,8 @@ public class CropActivity extends Activity { if (success) { setResult(RESULT_OK, intent); } else { + Toast.makeText(CropActivity.this, R.string.save_error, + Toast.LENGTH_LONG).show(); setResult(RESULT_CANCELED, intent); } done(); @@ -502,9 +504,13 @@ public class CropActivity extends Activity { fullSize = BitmapFactory.decodeStream(mInStream); } if (fullSize != null) { - crop = Bitmap.createBitmap(fullSize, roundedTrueCrop.left, - roundedTrueCrop.top, roundedTrueCrop.width(), - roundedTrueCrop.height()); + try { + crop = Bitmap.createBitmap(fullSize, roundedTrueCrop.left, + roundedTrueCrop.top, roundedTrueCrop.width(), + roundedTrueCrop.height()); + } catch (java.lang.OutOfMemoryError err) { + Log.e(LOGTAG, "failed to create bitmap:" + err ); + } } } |