pull/38/head
kunfei 6 years ago
parent 884eba851b
commit 0c0da8a893
  1. 10
      app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt

@ -25,9 +25,13 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
start: (() -> Unit)? = null, start: (() -> Unit)? = null,
finally: (() -> Unit)? = null finally: (() -> Unit)? = null
) { ) {
if (key.isEmpty()) return
task?.cancel() task?.cancel()
searchKey = key if (key.isEmpty()) {
searchPage++
} else {
searchKey = key
}
if (searchKey.isEmpty()) return
startTime = System.currentTimeMillis() startTime = System.currentTimeMillis()
start?.invoke() start?.invoke()
task = execute { task = execute {
@ -41,7 +45,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
for (item in bookSourceList) { for (item in bookSourceList) {
//task取消时自动取消 by (scope = this@execute) //task取消时自动取消 by (scope = this@execute)
WebBook(item).searchBook( WebBook(item).searchBook(
key, searchKey,
searchPage, searchPage,
scope = this@execute, scope = this@execute,
context = searchPool context = searchPool

Loading…
Cancel
Save