mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-16 20:00:36 +01:00
update Search, search subfolders too
This commit is contained in:
parent
c2ba395720
commit
b5d8980cd4
@ -51,7 +51,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:5.10.15'
|
||||
implementation 'com.simplemobiletools:commons:5.10.16'
|
||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||
implementation 'com.alexvasilkov:gesture-views:2.5.2'
|
||||
}
|
||||
|
@ -255,9 +255,32 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
||||
activity?.runOnUiThread {
|
||||
getRecyclerAdapter()?.updateItems(filtered, text)
|
||||
}
|
||||
|
||||
if (text.trim().length > 2) {
|
||||
val fileDirItems = ArrayList<FileDirItem>()
|
||||
fileDirItems.addAll(searchFiles(text.trim(), currentPath))
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun searchFiles(text: String, path: String): ArrayList<FileDirItem> {
|
||||
val files = ArrayList<FileDirItem>()
|
||||
val isSortingBySize = context!!.config.getFolderSorting(path) and SORT_BY_SIZE != 0
|
||||
File(path).listFiles()?.forEach {
|
||||
if (it.isDirectory) {
|
||||
files.addAll(searchFiles(text, it.absolutePath))
|
||||
} else {
|
||||
if (it.name.startsWith(text, true)) {
|
||||
val fileDirItem = getFileDirItemFromFile(it, isSortingBySize)
|
||||
if (fileDirItem != null) {
|
||||
files.add(fileDirItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
fun searchOpened() {
|
||||
isSearchOpen = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user