From 8c72bebe72e2e381ec3fa95e3208008d9fac23b4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Jul 2018 21:11:41 +0200 Subject: [PATCH] catch out of memory errors at saving images with filters --- .../gallery/activities/EditActivity.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 3aca45b31..82be5a8ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -228,9 +228,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener bottom_actions_filter_list.beGone() Thread { - val originalBitmap = Glide.with(applicationContext).asBitmap().load(uri).submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get() - currentFilter.filter.processFilter(originalBitmap) - saveBitmapToFile(originalBitmap, it, false) + try { + val originalBitmap = Glide.with(applicationContext).asBitmap().load(uri).submit(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get() + currentFilter.filter.processFilter(originalBitmap) + saveBitmapToFile(originalBitmap, it, false) + } catch (e: OutOfMemoryError) { + toast(R.string.out_of_memory_error) + } }.start() } }