|
|
|
@ -49,7 +49,9 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme |
|
|
|
|
ivChapterBottom.setColorFilter(btc) |
|
|
|
|
initRecyclerView() |
|
|
|
|
initView() |
|
|
|
|
initBook() |
|
|
|
|
viewModel.bookData.observe(this@ChapterListFragment) { |
|
|
|
|
initBook(it) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initRecyclerView() { |
|
|
|
@ -73,15 +75,13 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressLint("SetTextI18n") |
|
|
|
|
private fun initBook() { |
|
|
|
|
private fun initBook(book: Book) { |
|
|
|
|
launch { |
|
|
|
|
initDoc() |
|
|
|
|
viewModel.book?.let { |
|
|
|
|
durChapterIndex = it.durChapterIndex |
|
|
|
|
durChapterIndex = book.durChapterIndex |
|
|
|
|
binding.tvCurrentChapterInfo.text = |
|
|
|
|
"${it.durChapterTitle}(${it.durChapterIndex + 1}/${it.totalChapterNum})" |
|
|
|
|
initCacheFileNames(it) |
|
|
|
|
} |
|
|
|
|
"${book.durChapterTitle}(${book.durChapterIndex + 1}/${book.totalChapterNum})" |
|
|
|
|
initCacheFileNames(book) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -108,7 +108,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme |
|
|
|
|
|
|
|
|
|
override fun observeLiveBus() { |
|
|
|
|
observeEvent<BookChapter>(EventBus.SAVE_CONTENT) { chapter -> |
|
|
|
|
viewModel.book?.bookUrl?.let { bookUrl -> |
|
|
|
|
viewModel.bookData.value?.bookUrl?.let { bookUrl -> |
|
|
|
|
if (chapter.bookUrl == bookUrl) { |
|
|
|
|
adapter.cacheFileNames.add(chapter.getFileName()) |
|
|
|
|
adapter.notifyItemChanged(chapter.index, true) |
|
|
|
@ -130,7 +130,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override val isLocalBook: Boolean |
|
|
|
|
get() = viewModel.book?.isLocalBook() == true |
|
|
|
|
get() = viewModel.bookData.value?.isLocalBook() == true |
|
|
|
|
|
|
|
|
|
override fun durChapterIndex(): Int { |
|
|
|
|
return min(durChapterIndex, adapter.itemCount) |
|
|
|
|