diff options
author | kayiz <kaiyiz@codeaurora.org> | 2014-03-04 15:05:22 +0800 |
---|---|---|
committer | emancebo <emancebo@cyngn.com> | 2014-09-04 10:40:20 -0700 |
commit | f92a9bef39db56ec6ed325e917ac0fd7b50a2677 (patch) | |
tree | 892b119c78bd027951ed512d2b4522a36c841bd4 | |
parent | c74d68a54130c77c58bf2714cf0adb5a250d5304 (diff) | |
download | android_packages_apps_Gallery2-f92a9bef39db56ec6ed325e917ac0fd7b50a2677.tar.gz android_packages_apps_Gallery2-f92a9bef39db56ec6ed325e917ac0fd7b50a2677.tar.bz2 android_packages_apps_Gallery2-f92a9bef39db56ec6ed325e917ac0fd7b50a2677.zip |
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
-rw-r--r-- | src/com/android/gallery3d/filtershow/crop/CropActivity.java | 23 |
1 files changed, 11 insertions, 12 deletions
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); } |