diff --git a/app/src/main/java/io/legado/app/help/PrefExtensions.kt b/app/src/main/java/io/legado/app/help/PrefExtensions.kt index 3f6de591c..b9392ef7a 100644 --- a/app/src/main/java/io/legado/app/help/PrefExtensions.kt +++ b/app/src/main/java/io/legado/app/help/PrefExtensions.kt @@ -9,4 +9,4 @@ val Context.isShowRSS: Boolean get() = getPrefBoolean("showRss", true) val Context.threadCount: Int - get() = getPrefInt("threadCount", 6) \ No newline at end of file + get() = getPrefInt("threadCount", 16) \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index d8bfae260..6770f7db7 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -12,6 +12,7 @@ import io.legado.app.constant.Bus import io.legado.app.help.BookHelp import io.legado.app.help.IntentHelp import io.legado.app.help.coroutine.Coroutine +import io.legado.app.help.threadCount import io.legado.app.model.WebBook import io.legado.app.utils.postEvent import kotlinx.coroutines.Dispatchers.IO @@ -19,7 +20,8 @@ import kotlinx.coroutines.asCoroutineDispatcher import java.util.concurrent.Executors class DownloadService : BaseService() { - private var searchPool = Executors.newFixedThreadPool(16).asCoroutineDispatcher() + private var searchPool = + Executors.newFixedThreadPool(App.INSTANCE.threadCount).asCoroutineDispatcher() private var tasks: ArrayList> = arrayListOf() private val handler = Handler() private var runnable: Runnable = Runnable { upDownload() } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 1a695cccd..00148a7fd 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -7,6 +7,7 @@ import io.legado.app.constant.PreferKey import io.legado.app.data.entities.SearchBook import io.legado.app.data.entities.SearchKeyword import io.legado.app.help.coroutine.Coroutine +import io.legado.app.help.threadCount import io.legado.app.model.WebBook import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefString @@ -16,7 +17,8 @@ import kotlinx.coroutines.launch import java.util.concurrent.Executors class SearchViewModel(application: Application) : BaseViewModel(application) { - private var searchPool = Executors.newFixedThreadPool(16).asCoroutineDispatcher() + private var searchPool = + Executors.newFixedThreadPool(context.threadCount).asCoroutineDispatcher() private var task: Coroutine<*>? = null var callBack: CallBack? = null var searchKey: String = "" 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 2a81ae398..81dfcebe9 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 @@ -9,6 +9,7 @@ import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book import io.legado.app.data.entities.SearchBook import io.legado.app.help.coroutine.Coroutine +import io.legado.app.help.threadCount import io.legado.app.model.WebBook import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main @@ -18,7 +19,8 @@ import org.jetbrains.anko.debug import java.util.concurrent.Executors class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { - private var searchPool = Executors.newFixedThreadPool(16).asCoroutineDispatcher() + private var searchPool = + Executors.newFixedThreadPool(context.threadCount).asCoroutineDispatcher() var callBack: CallBack? = null val searchStateData = MutableLiveData() var name: String = ""