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 2cf9cae3d..ae44ddaad 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 @@ -76,6 +76,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se !getPrefBoolean(PreferKey.precisionSearch) ) precisionSearchMenuItem?.isChecked = getPrefBoolean(PreferKey.precisionSearch) + search_view.query.toString().trim()?.let { + search_view.setQuery(it, true) + } } R.id.menu_source_manage -> startActivity() else -> if (item.groupId == R.id.source_group) { @@ -85,6 +88,9 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } else { putPrefString("searchGroup", item.title.toString()) } + search_view.query.toString().trim()?.let { + search_view.setQuery(it, true) + } } } return super.onCompatOptionsItemSelected(item) diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 6bca4a5f4..1a695cccd 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -72,8 +72,8 @@ class SearchViewModel(application: Application) : BaseViewModel(application) { val books = arrayListOf() searchBooks.forEach { searchBook -> if (context.getPrefBoolean(PreferKey.precisionSearch)) { - if (searchBook.name.contains(searchKey) - || searchBook.author.contains(searchKey) + if (searchBook.name.equals(searchKey, true) + || searchBook.author.equals(searchKey, true) ) books.add(searchBook) } else books.add(searchBook)