diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt index 34a947270..7aa11f1c5 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt @@ -44,7 +44,7 @@ class SearchActivity : VMBaseActivity>? = null private var bookData: LiveData>? = null private var menu: Menu? = null @@ -57,7 +57,7 @@ class SearchActivity : VMBaseActivity startActivity() @@ -99,8 +99,8 @@ class SearchActivity : VMBaseActivity - if (!hasFocus && serchView.query.toString().trim().isEmpty()) { + searchView.setOnQueryTextFocusChangeListener { _, hasFocus -> + if (!hasFocus && searchView.query.toString().trim().isEmpty()) { finish() } else { openOrCloseHistory(hasFocus) @@ -207,9 +207,9 @@ class SearchActivity : VMBaseActivity { - serchView.setQuery(key, true) + searchView.query.toString() == key -> { + searchView.setQuery(key, true) } withContext(IO) { App.db.bookDao.findByName(key).isEmpty() } -> { - serchView.setQuery(key, true) + searchView.setQuery(key, true) } else -> { - serchView.setQuery(key, false) + searchView.setQuery(key, false) } } }