mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
fix #329, avoid some search glitches related to threading
This commit is contained in:
parent
5c2c057c83
commit
f99cb03c57
@ -40,6 +40,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||||||
private var showHidden = false
|
private var showHidden = false
|
||||||
private var skipItemUpdating = false
|
private var skipItemUpdating = false
|
||||||
private var isSearchOpen = false
|
private var isSearchOpen = false
|
||||||
|
private var lastSearchedText = ""
|
||||||
private var scrollStates = HashMap<String, Parcelable>()
|
private var scrollStates = HashMap<String, Parcelable>()
|
||||||
|
|
||||||
private var storedItems = ArrayList<ListItem>()
|
private var storedItems = ArrayList<ListItem>()
|
||||||
@ -266,6 +267,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||||||
|
|
||||||
fun searchQueryChanged(text: String) {
|
fun searchQueryChanged(text: String) {
|
||||||
val searchText = text.trim()
|
val searchText = text.trim()
|
||||||
|
lastSearchedText = searchText
|
||||||
Thread {
|
Thread {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
return@Thread
|
return@Thread
|
||||||
@ -289,6 +291,10 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val files = searchFiles(searchText, currentPath)
|
val files = searchFiles(searchText, currentPath)
|
||||||
|
if (lastSearchedText != searchText) {
|
||||||
|
return@Thread
|
||||||
|
}
|
||||||
|
|
||||||
val listItems = ArrayList<ListItem>()
|
val listItems = ArrayList<ListItem>()
|
||||||
|
|
||||||
var previousParent = ""
|
var previousParent = ""
|
||||||
@ -341,6 +347,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||||||
|
|
||||||
fun searchOpened() {
|
fun searchOpened() {
|
||||||
isSearchOpen = true
|
isSearchOpen = true
|
||||||
|
lastSearchedText = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchClosed() {
|
fun searchClosed() {
|
||||||
@ -349,6 +356,7 @@ class ItemsFragment : Fragment(), ItemOperationsListener, Breadcrumbs.Breadcrumb
|
|||||||
getRecyclerAdapter()?.updateItems(storedItems)
|
getRecyclerAdapter()?.updateItems(storedItems)
|
||||||
}
|
}
|
||||||
skipItemUpdating = false
|
skipItemUpdating = false
|
||||||
|
lastSearchedText = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createNewItem() {
|
private fun createNewItem() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user