pull/32/head
kunfei 5 years ago
parent 5970604607
commit df30bcafd0
  1. 27
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 9
      app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt
  3. 1
      app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt

@ -224,17 +224,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
launch { launch {
when (bookChapter.index) { when (bookChapter.index) {
viewModel.durChapterIndex -> { viewModel.durChapterIndex -> {
tv_chapter_name.text = bookChapter.title viewModel.curTextChapter =
tv_chapter_name.visible() ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
if (!viewModel.isLocalBook) {
tv_chapter_url.text = bookChapter.url
tv_chapter_url.visible()
}
ChapterProvider.getTextChapter(content_text_view, bookChapter, content).let {
viewModel.curTextChapter = it
page_view.upContent() page_view.upContent()
read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex) curChapterChange()
}
} }
viewModel.durChapterIndex - 1 -> { viewModel.durChapterIndex - 1 -> {
viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content)
@ -248,6 +241,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
} }
} }
private fun curChapterChange() {
viewModel.curTextChapter?.let {
tv_chapter_name.text = it.title
tv_chapter_name.visible()
if (!viewModel.isLocalBook) {
tv_chapter_url.text = it.url
tv_chapter_url.visible()
}
read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex)
}
}
override fun chapterSize(): Int { override fun chapterSize(): Int {
return viewModel.chapterSize return viewModel.chapterSize
} }
@ -293,10 +298,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
override fun moveToNextChapter() { override fun moveToNextChapter() {
viewModel.moveToNextChapter() viewModel.moveToNextChapter()
curChapterChange()
} }
override fun moveToPrevChapter() { override fun moveToPrevChapter() {
viewModel.moveToPrevChapter() viewModel.moveToPrevChapter()
curChapterChange()
} }
override fun clickCenter() { override fun clickCenter() {

@ -45,8 +45,13 @@ object ChapterProvider {
pageIndex++ pageIndex++
} }
return TextChapter(bookChapter.index, bookChapter.title, textPages, pageLengths) return TextChapter(
bookChapter.index,
bookChapter.title,
bookChapter.url,
textPages,
pageLengths
)
} }
} }

@ -3,6 +3,7 @@ package io.legado.app.ui.widget.page
data class TextChapter( data class TextChapter(
val position: Int, val position: Int,
val title: String, val title: String,
val url: String,
val pages: List<TextPage>, val pages: List<TextPage>,
val pageLengths: List<Int> val pageLengths: List<Int>
) { ) {

Loading…
Cancel
Save