pull/32/head
kunfei 5 years ago
parent f9525a2d24
commit 6843f39ccf
  1. 2
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt
  2. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt
  3. 2
      app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt

@ -50,7 +50,6 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
execute {
val bookSourceList = App.db.bookSourceDao().allEnabled
for (item in bookSourceList) {
delay(100)
//task取消时自动取消 by (scope = this@execute)
WebBook(item).searchBook(name, scope = this@execute)
.timeout(30000L)
@ -68,6 +67,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
}
}
}
delay(100)
}
}
}

@ -9,6 +9,7 @@ import io.legado.app.data.entities.BookGroup
import io.legado.app.model.WebBook
import io.legado.app.utils.postEvent
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.delay
class BookshelfViewModel(application: Application) : BaseViewModel(application) {
@ -48,6 +49,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
}
}
}
delay(50)
}
}
}

@ -29,7 +29,6 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
//onCleared时自动取消
val bookSourceList = App.db.bookSourceDao().allEnabled
for (item in bookSourceList) {
delay(100)//每隔100毫秒搜索一个书源
//task取消时自动取消 by (scope = this@execute)
WebBook(item).searchBook(key, searchPage, scope = this@execute)
.timeout(30000L)
@ -41,6 +40,7 @@ class SearchViewModel(application: Application) : BaseViewModel(application) {
}
}
}
delay(100)//每隔100毫秒搜索一个书源
}
}.onError {
it.printStackTrace()

Loading…
Cancel
Save