From 49584029197e5969a2dde3aafd796280dc06edd8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 27 Jun 2019 10:10:29 +0200 Subject: [PATCH] try catching an exception at an editor filter applying --- .../gallery/pro/activities/EditActivity.kt | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index 617e5207a..6a395f3e0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -583,18 +583,25 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (currPrimaryAction == PRIMARY_ACTION_FILTER && bottom_actions_filter_list.adapter == null) { Thread { val thumbnailSize = resources.getDimension(R.dimen.bottom_filters_thumbnail_size).toInt() - val bitmap = Glide.with(this) - .asBitmap() - .load(uri).listener(object : RequestListener { - override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { - showErrorToast(e.toString()) - return false - } - override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean) = false - }) - .submit(thumbnailSize, thumbnailSize) - .get() + val bitmap = try { + Glide.with(this) + .asBitmap() + .load(uri).listener(object : RequestListener { + override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { + showErrorToast(e.toString()) + return false + } + + override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target?, dataSource: DataSource?, isFirstResource: Boolean) = false + }) + .submit(thumbnailSize, thumbnailSize) + .get() + } catch (e: GlideException) { + showErrorToast(e) + finish() + return@Thread + } runOnUiThread { val filterThumbnailsManager = FilterThumbnailsManager()