From be54d59bd0354b3057d3a03236e7eeaf52db3bf5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 26 Apr 2018 11:30:58 +0200 Subject: [PATCH] properly look for empty OTG folders too --- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 4 +++- 1 file changed, 3 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 a931acfb6..0fd59ddd8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -760,7 +760,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { if (!getDoesFilePathExist(it.path)) { invalidDirs.add(it) } else { - val children = File(it.path).list() + val children = if (it.path.startsWith(OTG_PATH)) getOTGFolderChildren(it.path) else File(it.path).list()?.asList() val hasMediaFile = children?.any { it.isImageVideoGif() } ?: false if (!hasMediaFile) { invalidDirs.add(it) @@ -777,6 +777,8 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { } } + private fun getOTGFolderChildren(path: String) = getDocumentFile(path)?.listFiles()?.map { it.name }?.toList() + private fun getCurrentlyDisplayedDirs() = getRecyclerAdapter()?.dirs ?: ArrayList() private fun getBubbleTextItem(index: Int) = getRecyclerAdapter()?.dirs?.getOrNull(index)?.getBubbleText() ?: ""