From f92a9bef39db56ec6ed325e917ac0fd7b50a2677 Mon Sep 17 00:00:00 2001 From: kayiz Date: Tue, 4 Mar 2014 15:05:22 +0800 Subject: Gallery2: Fix cropped picture cannot be saved. When click the saveButton to save the cropped picture, We found the source picture uri and the cropped picture uri are the same,which cause the cropped picture can not be saved. Closed file Stream of mInStream before re-open it for the same file. CRs-Fixed: 622666 Change-Id: Ifcaa39ea76c141021259fad891411c59f7587903 --- .../gallery3d/filtershow/crop/CropActivity.java | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/com') diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java index 9a691f4a8..750c9afed 100644 --- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java +++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java @@ -402,16 +402,8 @@ public class CropActivity extends Activity { mOutputX = outputX; mOutputY = outputY; - if ((flags & DO_EXTRA_OUTPUT) != 0) { - if (mOutUri == null) { - Log.w(LOGTAG, "cannot write file, no output URI given"); - } else { - try { - mOutStream = getContentResolver().openOutputStream(mOutUri); - } catch (FileNotFoundException e) { - Log.w(LOGTAG, "cannot write file: " + mOutUri.toString(), e); - } - } + if ((flags & DO_EXTRA_OUTPUT) != 0 && mOutUri == null) { + Log.w(LOGTAG, "cannot write file, no output URI given"); } if ((flags & (DO_EXTRA_OUTPUT | DO_SET_WALLPAPER)) != 0) { @@ -556,7 +548,14 @@ public class CropActivity extends Activity { // Get output compression format CompressFormat cf = convertExtensionToCompressFormat(getFileExtension(mOutputFormat)); - + Utils.closeSilently(mInStream); + if (mOutUri != null) { + try { + mOutStream = getContentResolver().openOutputStream(mOutUri); + } catch (FileNotFoundException e) { + Log.w(LOGTAG, "cannot write file: " + mOutUri.toString(), e); + } + } // If we only need to output to a URI, compress straight to file if (mFlags == DO_EXTRA_OUTPUT) { if (mOutStream == null @@ -618,7 +617,7 @@ public class CropActivity extends Activity { @Override protected void onPostExecute(Boolean result) { Utils.closeSilently(mOutStream); - Utils.closeSilently(mInStream); + // Utils.closeSilently(mInStream); doneBitmapIO(result.booleanValue(), mResultIntent); } -- cgit v1.2.3