优化书籍更新

pull/346/head
gedoor 4 years ago
parent 99246d48ee
commit 41b120c0a6
  1. 5
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@ -23,7 +23,7 @@ import java.util.concurrent.CopyOnWriteArraySet
import java.util.concurrent.Executors import java.util.concurrent.Executors
class MainViewModel(application: Application) : BaseViewModel(application) { class MainViewModel(application: Application) : BaseViewModel(application) {
val threadCount = AppConfig.threadCount private var threadCount = AppConfig.threadCount
private var upTocPool = Executors.newFixedThreadPool(threadCount).asCoroutineDispatcher() private var upTocPool = Executors.newFixedThreadPool(threadCount).asCoroutineDispatcher()
val updateList = CopyOnWriteArraySet<String>() val updateList = CopyOnWriteArraySet<String>()
private val bookMap = ConcurrentHashMap<String, Book>() private val bookMap = ConcurrentHashMap<String, Book>()
@ -37,8 +37,9 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
} }
fun upPool() { fun upPool() {
threadCount = AppConfig.threadCount
upTocPool.close() upTocPool.close()
upTocPool = Executors.newFixedThreadPool(AppConfig.threadCount).asCoroutineDispatcher() upTocPool = Executors.newFixedThreadPool(threadCount).asCoroutineDispatcher()
} }
fun upAllBookToc() { fun upAllBookToc() {

Loading…
Cancel
Save