pull/2675/head
kunfei 2 years ago
parent 5574399371
commit 5e02358c3c
  1. 10
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt

@ -185,9 +185,9 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
searchView.queryHint = getString(R.string.search_book_key) searchView.queryHint = getString(R.string.search_book_key)
searchView.clearFocus() searchView.clearFocus()
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean { override fun onQueryTextSubmit(query: String): Boolean {
searchView.clearFocus() searchView.clearFocus()
query?.trim()?.let { searchKey -> query.trim().let { searchKey ->
isManualStopSearch = false isManualStopSearch = false
viewModel.saveSearchKey(searchKey) viewModel.saveSearchKey(searchKey)
viewModel.searchKey = "" viewModel.searchKey = ""
@ -197,9 +197,9 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
return true return true
} }
override fun onQueryTextChange(newText: String?): Boolean { override fun onQueryTextChange(newText: String): Boolean {
if (newText.isNullOrBlank()) viewModel.stop() if (newText.isBlank()) viewModel.stop()
upHistory(newText?.trim()) upHistory(newText.trim())
return false return false
} }
}) })

@ -78,12 +78,12 @@ class SearchContentActivity :
searchView.clearFocus() searchView.clearFocus()
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean { override fun onQueryTextSubmit(query: String): Boolean {
startContentSearch(query) startContentSearch(query.trim())
searchView.clearFocus() searchView.clearFocus()
return false return false
} }
override fun onQueryTextChange(newText: String?): Boolean { override fun onQueryTextChange(newText: String): Boolean {
return false return false
} }
}) })

Loading…
Cancel
Save