From f066f4b84a3723f1f2668255d42bfbc361e1fe48 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 27 Jun 2019 09:52:11 +0200 Subject: [PATCH] catch exceptions thrown at clearing the recycle bin --- .../gallery/pro/extensions/Activity.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index e3130cca5..77bd3fd9d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -293,11 +293,15 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList, mediumDa fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) { Thread { - recycleBin.deleteRecursively() - galleryDB.MediumDao().clearRecycleBin() - galleryDB.DirectoryDao().deleteRecycleBin() - toast(R.string.recycle_bin_emptied) - callback?.invoke() + try { + recycleBin.deleteRecursively() + galleryDB.MediumDao().clearRecycleBin() + galleryDB.DirectoryDao().deleteRecycleBin() + toast(R.string.recycle_bin_emptied) + callback?.invoke() + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) + } }.start() }