From 3aaa17a02d050b137a5751772bba18d6ad70dc40 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Apr 2018 10:10:34 +0200 Subject: [PATCH] fixing a couple crashes --- .../gallery/activities/MediaActivity.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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 2d9becbeb..aa9580b9a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -42,6 +42,7 @@ import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.activity_media.* import java.io.File import java.io.IOException +import java.util.* class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private val LAST_MEDIA_CHECK_PERIOD = 3000L @@ -458,7 +459,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { if (!mLoadedInitialPhotos) { getCachedMedia(mPath, mIsGetVideoIntent, mIsGetImageIntent) { if (it.isEmpty()) { - media_refresh_layout.isRefreshing = true + runOnUiThread { + media_refresh_layout.isRefreshing = true + } } else { gotMedia(it, true) } @@ -634,7 +637,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mLatestMediaId = getLatestMediaId() mLatestMediaDateId = getLatestMediaByDateId() if (!isFromCache) { - galleryDB.MediumDao().insertAll(media) + try { + galleryDB.MediumDao().insertAll(media) + } catch (e: ConcurrentModificationException) { + } } }.start()