revert back to the previous way of listing otg files

This commit is contained in:
tibbi 2019-03-27 19:48:16 +01:00
parent 84b0737882
commit 174d55ee37
1 changed files with 16 additions and 2 deletions

View File

@ -173,8 +173,13 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) { private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
skipItemUpdating = false skipItemUpdating = false
Thread { Thread {
if (activity?.isDestroyed == false) { if (activity?.isDestroyed == false && activity?.isFinishing == false) {
if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) { 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) getRegularItemsOf(path, callback)
} else { } else {
RootHelpers(activity!!).getFiles(path, callback) RootHelpers(activity!!).getFiles(path, callback)
@ -226,6 +231,15 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
return ListItem(curPath, curName, isDirectory, children, size, false) return ListItem(curPath, curName, isDirectory, children, size, false)
} }
private fun getListItemsFromFileDirItems(fileDirItems: ArrayList<FileDirItem>): ArrayList<ListItem> {
val listItems = ArrayList<ListItem>()
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) { private fun itemClicked(item: FileDirItem) {
if (item.isDirectory) { if (item.isDirectory) {
(activity as? MainActivity)?.apply { (activity as? MainActivity)?.apply {