diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index fc096de5f..938424fe2 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.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) } } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index 451b6443f..0accc1813 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -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) } } } diff --git a/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt index 33381933b..0fbb8c772 100644 --- a/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/search/SearchViewModel.kt @@ -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()