From b6a266d4365829718257a09f8843c50a4be66787 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 27 Oct 2017 14:02:11 +0200 Subject: [PATCH] always set saveUri at editor activity --- .../gallery/activities/EditActivity.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index db8277eba..53c278d5e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -24,7 +24,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private val CROP = "crop" lateinit var uri: Uri - var saveUri: Uri? = null + lateinit var saveUri: Uri var resizeWidth = 0 var resizeHeight = 0 var isCropIntent = false @@ -47,8 +47,10 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return } - if (intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true) { - saveUri = intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri + saveUri = if (intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true) { + intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri + } else { + uri } isCropIntent = intent.extras?.get(CROP) == "true" @@ -128,7 +130,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener override fun onCropImageComplete(view: CropImageView, result: CropImageView.CropResult) { if (result.error == null) { - if (isCropIntent && saveUri != null) { + if (isCropIntent) { var inputStream: InputStream? = null var outputStream: OutputStream? = null try { @@ -143,12 +145,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } setResult(RESULT_OK) finish() - } else if (saveUri?.scheme == "file") { - SaveAsDialog(this, saveUri!!.path, true) { + } else if (saveUri.scheme == "file") { + SaveAsDialog(this, saveUri.path, true) { saveBitmapToFile(result.bitmap, it) } - } else if (saveUri?.scheme == "content") { - val newPath = applicationContext.getRealPathFromURI(saveUri!!) ?: "" + } else if (saveUri.scheme == "content") { + val newPath = applicationContext.getRealPathFromURI(saveUri) ?: "" if (!newPath.isEmpty()) { SaveAsDialog(this, newPath, true) { saveBitmapToFile(result.bitmap, it)