chore: cancel search when return (#465)

Signed-off-by: HystericalDragon <HystericalDragons@proton.me>
This commit is contained in:
HystericalDragon 2023-12-03 22:35:46 +08:00 committed by GitHub
parent 857dcaf0d8
commit bca302de5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,6 +147,12 @@ class ConfigurationFragment @JvmOverloads constructor(
if (searchView != null) {
searchView.setOnQueryTextListener(this)
searchView.maxWidth = Int.MAX_VALUE
searchView.setOnQueryTextFocusChangeListener { _, hasFocus ->
if (!hasFocus) {
cancelSearch(searchView)
}
}
}
groupPager = view.findViewById(R.id.group_pager)
@ -1701,4 +1707,9 @@ class ConfigurationFragment @JvmOverloads constructor(
}
}
}
private fun cancelSearch(searchView: SearchView) {
searchView.onActionViewCollapsed()
searchView.clearFocus()
}
}