Skip to content

Commit 174d55e

Browse files
committed
revert back to the previous way of listing otg files
1 parent 84b0737 commit 174d55e

File tree

1 file changed

+16
-2
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments

1 file changed

+16
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/ItemsFragment.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,13 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
173173
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
174174
skipItemUpdating = false
175175
Thread {
176-
if (activity?.isDestroyed == false) {
177-
if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
176+
if (activity?.isDestroyed == false && activity?.isFinishing == false) {
177+
if (context!!.isPathOnOTG(path)) {
178+
val getProperFileSize = context!!.config.sorting and SORT_BY_SIZE != 0
179+
context!!.getOTGItems(path, context!!.config.shouldShowHidden, getProperFileSize) {
180+
callback(path, getListItemsFromFileDirItems(it))
181+
}
182+
} else if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
178183
getRegularItemsOf(path, callback)
179184
} else {
180185
RootHelpers(activity!!).getFiles(path, callback)
@@ -226,6 +231,15 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
226231
return ListItem(curPath, curName, isDirectory, children, size, false)
227232
}
228233

234+
private fun getListItemsFromFileDirItems(fileDirItems: ArrayList<FileDirItem>): ArrayList<ListItem> {
235+
val listItems = ArrayList<ListItem>()
236+
fileDirItems.forEach {
237+
val listItem = ListItem(it.path, it.name, it.isDirectory, it.children, it.size, false)
238+
listItems.add(listItem)
239+
}
240+
return listItems
241+
}
242+
229243
private fun itemClicked(item: FileDirItem) {
230244
if (item.isDirectory) {
231245
(activity as? MainActivity)?.apply {

0 commit comments

Comments
 (0)