From 1c433b1ebfc1380ef544c838c017e0049d9c19ff Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Dec 2017 20:53:17 +0100 Subject: [PATCH] make sure we call getLatestMediaId from a background thread --- .../simplemobiletools/gallery/activities/MainActivity.kt | 6 ++++-- .../simplemobiletools/gallery/activities/MediaActivity.kt | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 05baef15e..d113f63b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -526,9 +526,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } private fun gotDirectories(newDirs: ArrayList, isFromCache: Boolean) { - val dirs = getSortedDirectories(newDirs) + Thread { + mLatestMediaId = getLatestMediaId() + }.start() - mLatestMediaId = getLatestMediaId() + val dirs = getSortedDirectories(newDirs) directories_refresh_layout.isRefreshing = false mIsGettingDirs = false 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 c432843bb..7613096c8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -537,7 +537,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } private fun gotMedia(media: ArrayList, isFromCache: Boolean = false) { - mLatestMediaId = getLatestMediaId() + Thread { + mLatestMediaId = getLatestMediaId() + }.start() + mIsGettingMedia = false media_refresh_layout.isRefreshing = false