pull/1604/head
kunfei 3 years ago
parent 5520ffc2fd
commit 0039473314
  1. 11
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt

@ -22,12 +22,9 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.ColorUtils import io.legado.app.utils.ColorUtils
import io.legado.app.utils.observeEvent import io.legado.app.utils.observeEvent
import io.legado.app.utils.viewbindingdelegate.viewBinding import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapter_list), class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapter_list),
ChapterListAdapter.Callback, ChapterListAdapter.Callback,
@ -119,7 +116,11 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
} }
val useReplace = viewModel.bookData.value?.getUseReplaceRule() == true val useReplace = viewModel.bookData.value?.getUseReplaceRule() == true
it.map { chapter -> it.map { chapter ->
Pair(chapter, async { chapter.getDisplayTitle(replaces, useReplace) }) Pair(
chapter,
async(start = CoroutineStart.LAZY) {
chapter.getDisplayTitle(replaces, useReplace)
})
} }
} }
adapter.setItems(data, adapter.diffCallBack) adapter.setItems(data, adapter.diffCallBack)

Loading…
Cancel
Save