From 5bfde1b6fe750da82ce9e78fdb79d24bfdceded9 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 4 Oct 2019 13:30:43 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/book/search/SearchActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 bc25fa64f..f9124f9fb 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 @@ -23,6 +23,9 @@ import io.legado.app.utils.invisible import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_book_search.* import kotlinx.android.synthetic.main.view_search.* +import kotlinx.coroutines.Dispatchers.IO +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity @@ -166,6 +169,12 @@ class SearchActivity : VMBaseActivity(R.layout.activity_book_se } override fun searchHistory(key: String) { - search_view.setQuery(key, false) + launch { + if (withContext(IO) { App.db.bookDao().findByName(key).isEmpty() }) { + search_view.setQuery(key, true) + } else { + search_view.setQuery(key, false) + } + } } }