From d8fad97da222588027c45f05f344a22af3d47ae1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 19 May 2021 23:12:44 +0200 Subject: [PATCH] make sure Recents are loaded properly at first launch, after granting permission --- .../filemanager/pro/activities/MainActivity.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt index 79c5ede3..956f70fa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MainActivity.kt @@ -259,6 +259,7 @@ class MainActivity : SimpleActivity() { } private fun tryInitFileManager() { + val hadPermission = hasPermission(PERMISSION_WRITE_STORAGE) handlePermission(PERMISSION_WRITE_STORAGE) { checkOTGPath() if (it) { @@ -267,7 +268,7 @@ class MainActivity : SimpleActivity() { } main_view_pager.onGlobalLayout { - initFileManager() + initFileManager(!hadPermission) } } else { toast(R.string.no_storage_permissions) @@ -276,7 +277,7 @@ class MainActivity : SimpleActivity() { } } - private fun initFileManager() { + private fun initFileManager(refreshRecents: Boolean) { if (intent.action == Intent.ACTION_VIEW && intent.data != null) { val data = intent.data if (data?.scheme == "file") { @@ -302,6 +303,10 @@ class MainActivity : SimpleActivity() { it?.isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT it?.isPickMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) } + + if (refreshRecents) { + recents_fragment?.refreshItems() + } } private fun initFragments() {