|
|
@ -49,6 +49,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea |
|
|
|
initView() |
|
|
|
initView() |
|
|
|
viewModel.callBack = this |
|
|
|
viewModel.callBack = this |
|
|
|
viewModel.chapterMaxIndex.observe(this, Observer { bookLoadFinish() }) |
|
|
|
viewModel.chapterMaxIndex.observe(this, Observer { bookLoadFinish() }) |
|
|
|
|
|
|
|
viewModel.bookData.observe(this, Observer { title_bar.title = it.name }) |
|
|
|
viewModel.initData(intent) |
|
|
|
viewModel.initData(intent) |
|
|
|
savedInstanceState?.let { |
|
|
|
savedInstanceState?.let { |
|
|
|
changeSourceDialog = supportFragmentManager.findFragmentByTag(ChangeSourceDialog.tag) as? ChangeSourceDialog |
|
|
|
changeSourceDialog = supportFragmentManager.findFragmentByTag(ChangeSourceDialog.tag) as? ChangeSourceDialog |
|
|
@ -145,7 +146,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun openChapterList() { |
|
|
|
override fun openChapterList() { |
|
|
|
viewModel.book?.let { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
startActivity<ChapterListActivity>(Pair("bookUrl", it.bookUrl)) |
|
|
|
startActivity<ChapterListActivity>(Pair("bookUrl", it.bookUrl)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -182,7 +183,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea |
|
|
|
when (item.itemId) { |
|
|
|
when (item.itemId) { |
|
|
|
R.id.menu_change_source -> { |
|
|
|
R.id.menu_change_source -> { |
|
|
|
if (changeSourceDialog == null) { |
|
|
|
if (changeSourceDialog == null) { |
|
|
|
viewModel.book?.let { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
changeSourceDialog = ChangeSourceDialog.newInstance(it.name, it.author) |
|
|
|
changeSourceDialog = ChangeSourceDialog.newInstance(it.name, it.author) |
|
|
|
changeSourceDialog?.callBack = this |
|
|
|
changeSourceDialog?.callBack = this |
|
|
|
} |
|
|
|
} |
|
|
@ -229,7 +230,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun bookLoadFinish() { |
|
|
|
private fun bookLoadFinish() { |
|
|
|
viewModel.book?.let { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
viewModel.loadContent(it, it.durChapterIndex) |
|
|
|
viewModel.loadContent(it, it.durChapterIndex) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -252,7 +253,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea |
|
|
|
} |
|
|
|
} |
|
|
|
when (readAloudStatus) { |
|
|
|
when (readAloudStatus) { |
|
|
|
Status.STOP -> { |
|
|
|
Status.STOP -> { |
|
|
|
viewModel.book?.let { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
ReadAloudService.paly(this, it.name, "", "") |
|
|
|
ReadAloudService.paly(this, it.name, "", "") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|