do not trim searched text on main tab

This commit is contained in:
tibbi 2023-01-07 21:06:32 +01:00
parent b850c19205
commit bce66e3cde
1 changed files with 5 additions and 6 deletions

View File

@ -295,22 +295,21 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
} }
override fun searchQueryChanged(text: String) { override fun searchQueryChanged(text: String) {
val searchText = text.trim() lastSearchedText = text
lastSearchedText = searchText
if (context == null) { if (context == null) {
return return
} }
items_swipe_refresh.isEnabled = text.isEmpty() && activity?.config?.enablePullToRefresh != false items_swipe_refresh.isEnabled = text.isEmpty() && activity?.config?.enablePullToRefresh != false
when { when {
searchText.isEmpty() -> { text.isEmpty() -> {
items_fastscroller.beVisible() items_fastscroller.beVisible()
getRecyclerAdapter()?.updateItems(itemsIgnoringSearch) getRecyclerAdapter()?.updateItems(itemsIgnoringSearch)
items_placeholder.beGone() items_placeholder.beGone()
items_placeholder_2.beGone() items_placeholder_2.beGone()
hideProgressBar() hideProgressBar()
} }
searchText.length == 1 -> { text.length == 1 -> {
items_fastscroller.beGone() items_fastscroller.beGone()
items_placeholder.beVisible() items_placeholder.beVisible()
items_placeholder_2.beVisible() items_placeholder_2.beVisible()
@ -319,10 +318,10 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
else -> { else -> {
showProgressBar() showProgressBar()
ensureBackgroundThread { ensureBackgroundThread {
val files = searchFiles(searchText, currentPath) val files = searchFiles(text, currentPath)
files.sortBy { it.getParentPath() } files.sortBy { it.getParentPath() }
if (lastSearchedText != searchText) { if (lastSearchedText != text) {
return@ensureBackgroundThread return@ensureBackgroundThread
} }