pull/1649/head
kunfei 3 years ago
parent 5e581ee628
commit 9e0e47c15e
  1. 4
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverViewModel.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceViewModel.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceViewModel.kt

@ -4,7 +4,6 @@ import android.app.Application
import android.os.Bundle
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import cn.hutool.core.collection.ConcurrentHashSet
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppPattern
@ -21,6 +20,7 @@ import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.flowOn
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.min
@ -34,7 +34,7 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application
var name: String = ""
var author: String = ""
val dataFlow = callbackFlow<List<SearchBook>> {
val searchBooks = ConcurrentHashSet<SearchBook>()
val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
searchSuccess = {
if (!searchBooks.contains(it)) {

@ -4,7 +4,6 @@ import android.app.Application
import android.os.Bundle
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import cn.hutool.core.collection.ConcurrentHashSet
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppPattern
@ -28,6 +27,7 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import splitties.init.appCtx
import timber.log.Timber
import java.util.*
import java.util.concurrent.Executors
import kotlin.math.min
@ -41,7 +41,7 @@ class ChangeBookSourceViewModel(application: Application) : BaseViewModel(applic
private var tasks = CompositeCoroutine()
private var screenKey: String = ""
private var bookSourceList = arrayListOf<BookSource>()
private val searchBooks = ConcurrentHashSet<SearchBook>()
private val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
private val searchGroup get() = appCtx.getPrefString("searchGroup") ?: ""
private var searchCallback: SourceCallback? = null
val searchDataFlow = callbackFlow {

@ -4,7 +4,6 @@ import android.app.Application
import android.os.Bundle
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import cn.hutool.core.collection.ConcurrentHashSet
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppConst
import io.legado.app.constant.AppPattern
@ -30,6 +29,7 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import splitties.init.appCtx
import timber.log.Timber
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executors
import kotlin.math.min
@ -47,7 +47,7 @@ class ChangeChapterSourceViewModel(application: Application) : BaseViewModel(app
private var tasks = CompositeCoroutine()
private var screenKey: String = ""
private var bookSourceList = arrayListOf<BookSource>()
private val searchBooks = ConcurrentHashSet<SearchBook>()
private val searchBooks = Collections.synchronizedList(arrayListOf<SearchBook>())
private val tocMap = ConcurrentHashMap<String, List<BookChapter>>()
private var searchCallback: SourceCallback? = null
val searchDataFlow = callbackFlow {

Loading…
Cancel
Save