From 2634e09f7f564ec20e4d98c763ea83fe14fb8010 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 5 Dec 2021 16:54:19 +0100 Subject: [PATCH] avoid fetching the files multiple times at first launch --- .../gallery/pro/activities/MainActivity.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index c0986554f..c20919dbc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -434,7 +434,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun tryLoadGallery() { + // avoid calling anything right after granting the permission, it will be called from onResume() + val wasMissingPermission = config.appRunCount == 1 && !hasPermission(PERMISSION_WRITE_STORAGE) handlePermission(PERMISSION_WRITE_STORAGE) { + if (wasMissingPermission) { + return@handlePermission + } + if (it) { if (!mWasDefaultFolderChecked) { openDefaultFolder() @@ -1068,7 +1074,9 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } mLoadedInitialPhotos = true - checkLastMediaChanged() + if (config.appRunCount > 1) { + checkLastMediaChanged() + } runOnUiThread { directories_refresh_layout.isRefreshing = false