pull/1606/head
kunfei 3 years ago
parent a23a40a933
commit 2df5c58a0a
  1. 9
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListAdapter.kt

@ -18,6 +18,8 @@ import io.legado.app.utils.gone
import io.legado.app.utils.visible
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import java.util.concurrent.ConcurrentHashMap
@ -56,12 +58,17 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
}
private val useReplace
get() = AppConfig.tocUiUseReplace && callback.book?.getUseReplaceRule() == true
private var upDisplayTileJob: Job? = null
fun upDisplayTile() {
callback.scope.launch(IO) {
upDisplayTileJob?.cancel()
upDisplayTileJob = callback.scope.launch(IO) {
val replaceRules = replaceRules
val useReplace = useReplace
getItems().forEach {
if (!isActive) {
return@launch
}
if (displayTileMap[it.index] == null) {
displayTileMap[it.index] = it.getDisplayTitle(replaceRules, useReplace)
}

Loading…
Cancel
Save