From 150aace3ca5ca7ee189401ffce5385fbdf4c6596 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 29 May 2020 21:25:41 +0200 Subject: [PATCH] properly catch exceptions thrown in the background --- .../gallery/pro/activities/MediaActivity.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 5ac44db95..632544e80 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -872,12 +872,12 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { mLatestMediaDateId = getLatestMediaByDateId() if (!isFromCache) { val mediaToInsert = (mMedia).filter { it is Medium && it.deletedTS == 0L }.map { it as Medium } - try { - Thread { + Thread { + try { mediaDB.insertAll(mediaToInsert) - }.start() - } catch (e: Exception) { - } + } catch (e: Exception) { + } + }.start() } }