From 174d55ee37a9ff1a2528dd00397c600507a16908 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 27 Mar 2019 19:48:16 +0100 Subject: [PATCH] revert back to the previous way of listing otg files --- .../filemanager/pro/fragments/ItemsFragment.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt index cfff335e..0585e898 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt @@ -173,8 +173,13 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb private fun getItems(path: String, callback: (originalPath: String, items: ArrayList) -> Unit) { skipItemUpdating = false Thread { - if (activity?.isDestroyed == false) { - if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { + if (activity?.isDestroyed == false && activity?.isFinishing == false) { + if (context!!.isPathOnOTG(path)) { + val getProperFileSize = context!!.config.sorting and SORT_BY_SIZE != 0 + context!!.getOTGItems(path, context!!.config.shouldShowHidden, getProperFileSize) { + callback(path, getListItemsFromFileDirItems(it)) + } + } else if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { getRegularItemsOf(path, callback) } else { RootHelpers(activity!!).getFiles(path, callback) @@ -226,6 +231,15 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb return ListItem(curPath, curName, isDirectory, children, size, false) } + private fun getListItemsFromFileDirItems(fileDirItems: ArrayList): ArrayList { + val listItems = ArrayList() + fileDirItems.forEach { + val listItem = ListItem(it.path, it.name, it.isDirectory, it.children, it.size, false) + listItems.add(listItem) + } + return listItems + } + private fun itemClicked(item: FileDirItem) { if (item.isDirectory) { (activity as? MainActivity)?.apply {