优化发现筛选逻辑

This commit is contained in:
HapeLee
2025-10-20 23:16:10 +08:00
parent deae2069a8
commit a7bfa4bf17
@@ -74,6 +74,7 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
private val groups = linkedSetOf<String>()
private var exploreFlowJob: Job? = null
private var groupsMenu: SubMenu? = null
private var currentSearchKey: String? = null
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
setSupportToolbar(binding.topBar)
@@ -89,8 +90,8 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
}
private fun initSearchView() {
searchView.setupWithSearchBar(searchBar)
searchView.hint = getString(R.string.screen_find)
searchBar.setOnClickListener {
searchView.show()
if (searchView.text.isEmpty()) {
@@ -98,6 +99,12 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
}
}
searchView.addTransitionListener { _, _, newState ->
if (newState == SearchView.TransitionState.HIDDEN) {
searchBar.setText(searchView.text)
}
}
searchView.editText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
val query = searchView.text.toString()
@@ -114,7 +121,6 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
searchView.editText.doAfterTextChanged { editable ->
editable?.let {
upExploreData(it.toString())
if (it.isEmpty()) {
searchBar.hint = getString(R.string.screen_find)
}