From c27182284483da6712578fd34889f55d59a4b0ce Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Feb 2018 19:27:31 +0100 Subject: [PATCH] check storage permission before getting latest media id --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 3fabb044d..d2df2fcf4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -17,6 +17,7 @@ import com.simplemobiletools.commons.dialogs.CreateNewFolderDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* +import com.simplemobiletools.commons.helpers.PERMISSION_READ_STORAGE import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN @@ -634,7 +635,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private fun setupLatestMediaId() { Thread { - mLatestMediaId = getLatestMediaId() + if (hasPermission(PERMISSION_READ_STORAGE)) { + mLatestMediaId = getLatestMediaId() + } }.start() }