pull/32/head
kunfei 5 years ago
parent a34dfb9a33
commit 99bb0b1ebb
  1. 9
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt

@ -60,7 +60,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
page_view.callback = this page_view.callback = this
viewModel.callBack = this viewModel.callBack = this
viewModel.bookData.observe(this, Observer { title_bar.title = it.name }) viewModel.bookData.observe(this, Observer { title_bar.title = it.name })
viewModel.chapterListFinish.observe(this, Observer { bookLoadFinish() }) viewModel.chapterListFinish.observe(this, Observer { loadContent() })
viewModel.initData(intent) viewModel.initData(intent)
savedInstanceState?.let { savedInstanceState?.let {
changeSourceDialog = changeSourceDialog =
@ -234,9 +234,9 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
} }
/** /**
* 书籍加载完成,开始加载章节内容 * 加载章节内容
*/ */
private fun bookLoadFinish() { private fun loadContent() {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
viewModel.loadContent(it, viewModel.durChapterIndex) viewModel.loadContent(it, viewModel.durChapterIndex)
viewModel.loadContent(it, viewModel.durChapterIndex + 1) viewModel.loadContent(it, viewModel.durChapterIndex + 1)
@ -460,6 +460,9 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
page_view.upBg() page_view.upBg()
content_view.upStyle() content_view.upStyle()
page_view.upStyle() page_view.upStyle()
if (it) {
loadContent()
}
} }
observeEvent<Int>(Bus.TTS_START) { chapterStart -> observeEvent<Int>(Bus.TTS_START) { chapterStart ->
launch(IO) { launch(IO) {

@ -124,31 +124,31 @@ class ReadStyleDialog : DialogFragment() {
ReadBookConfig.styleSelect = 0 ReadBookConfig.styleSelect = 0
ReadBookConfig.upBg() ReadBookConfig.upBg()
upBg() upBg()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, false)
} }
tv_bg1.onClick { tv_bg1.onClick {
ReadBookConfig.styleSelect = 1 ReadBookConfig.styleSelect = 1
ReadBookConfig.upBg() ReadBookConfig.upBg()
upBg() upBg()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, false)
} }
tv_bg2.onClick { tv_bg2.onClick {
ReadBookConfig.styleSelect = 2 ReadBookConfig.styleSelect = 2
ReadBookConfig.upBg() ReadBookConfig.upBg()
upBg() upBg()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, false)
} }
tv_bg3.onClick { tv_bg3.onClick {
ReadBookConfig.styleSelect = 3 ReadBookConfig.styleSelect = 3
ReadBookConfig.upBg() ReadBookConfig.upBg()
upBg() upBg()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, false)
} }
tv_bg4.onClick { tv_bg4.onClick {
ReadBookConfig.styleSelect = 4 ReadBookConfig.styleSelect = 4
ReadBookConfig.upBg() ReadBookConfig.upBg()
upBg() upBg()
postEvent(Bus.UP_CONFIG, true) postEvent(Bus.UP_CONFIG, false)
} }
} }

Loading…
Cancel
Save