From 4f724786b2ea80d01ee349025e7fe640d62c8994 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Apr 2018 13:31:26 +0200 Subject: [PATCH] fix media inserting ConcurrentModificationException in a proper way --- .../simplemobiletools/gallery/activities/MediaActivity.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index aa9580b9a..6d2ae0170 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -633,14 +633,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun gotMedia(media: ArrayList, isFromCache: Boolean = false) { + val mediaToInsert = media.clone() as ArrayList Thread { mLatestMediaId = getLatestMediaId() mLatestMediaDateId = getLatestMediaByDateId() if (!isFromCache) { - try { - galleryDB.MediumDao().insertAll(media) - } catch (e: ConcurrentModificationException) { - } + galleryDB.MediumDao().insertAll(mediaToInsert) } }.start()