pull/43/head^2
kunfei 5 years ago
parent 22779b2150
commit 80ff827671
  1. 2
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  2. 11
      app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt

@ -171,7 +171,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
}
private fun scrollToBottom() {
if (!viewModel.isLoading) {
if (!viewModel.isLoading && viewModel.searchKey.isNotEmpty()) {
viewModel.search("")
}
}

@ -27,17 +27,20 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
fun search(key: String) {
task?.cancel()
if (key.isEmpty()) {
if (key.isEmpty() && searchKey.isEmpty()) {
return
} else if (key.isEmpty()) {
isLoading = true
searchPage++
} else {
} else if (key.isNotEmpty()) {
isLoading = true
searchPage = 0
searchKey = key
searchBooks.clear()
}
if (searchKey.isEmpty()) return
startTime = System.currentTimeMillis()
callBack?.startSearch()
task = execute {
isLoading = true
val searchGroup = context.getPrefString("searchGroup") ?: ""
val bookSourceList = if (searchGroup.isBlank()) {
App.db.bookSourceDao().allEnabled

Loading…
Cancel
Save