create a helper function for converting files to FileDirItems
This commit is contained in:
parent
3af942c5a2
commit
2fb89645e5
|
@ -51,7 +51,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.10.12'
|
||||
implementation 'com.simplemobiletools:commons:5.10.15'
|
||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||
}
|
||||
|
|
|
@ -193,10 +193,21 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
val isSortingBySize = context!!.config.sorting and SORT_BY_SIZE != 0
|
||||
if (files != null) {
|
||||
for (file in files) {
|
||||
val fileDirItem = getFileDirItemFromFile(file, isSortingBySize)
|
||||
if (fileDirItem != null) {
|
||||
items.add(fileDirItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback(path, items)
|
||||
}
|
||||
|
||||
private fun getFileDirItemFromFile(file: File, isSortingBySize: Boolean): FileDirItem? {
|
||||
val curPath = file.absolutePath
|
||||
val curName = file.name
|
||||
if (!showHidden && curName.startsWith(".")) {
|
||||
continue
|
||||
return null
|
||||
}
|
||||
|
||||
val isDirectory = file.isDirectory
|
||||
|
@ -210,12 +221,8 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||
} else {
|
||||
file.length()
|
||||
}
|
||||
val fileDirItem = FileDirItem(curPath, curName, isDirectory, children, size)
|
||||
items.add(fileDirItem)
|
||||
}
|
||||
}
|
||||
|
||||
callback(path, items)
|
||||
return FileDirItem(curPath, curName, isDirectory, children, size)
|
||||
}
|
||||
|
||||
private fun itemClicked(item: FileDirItem) {
|
||||
|
|
Loading…
Reference in New Issue