From 88d8f39118ff339482dec391f7281890d8ee30b0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 Dec 2017 22:20:10 +0100 Subject: [PATCH] handle whole bitmap saving in edit activity on a background thread --- .../gallery/activities/EditActivity.kt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 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 d41ba13c4..8e3d4d6c4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -184,18 +184,17 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun saveBitmapToFile(bitmap: Bitmap, path: String) { - val file = File(path) - try { - getFileOutputStream(file) { - if (it != null) { - Thread { + Thread { + val file = File(path) + getFileOutputStream(file) { + if (it != null) { saveBitmap(file, bitmap, it) - }.start() - } else { - toast(R.string.image_editing_failed) + } else { + toast(R.string.image_editing_failed) + } } - } + }.start() } catch (e: Exception) { showErrorToast(e) } catch (e: OutOfMemoryError) {