pull/84/head
kunfei 5 years ago
parent 1d3bcac3d7
commit d353007988
  1. 21
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudDialog.kt

@ -67,6 +67,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
private val requestCodeChapterList = 568 private val requestCodeChapterList = 568
private val requestCodeEditSource = 111 private val requestCodeEditSource = 111
private val requestCodeReplace = 312 private val requestCodeReplace = 312
private var replaceUseMenu: MenuItem? = null
override val viewModel: ReadBookViewModel override val viewModel: ReadBookViewModel
get() = getViewModel(ReadBookViewModel::class.java) get() = getViewModel(ReadBookViewModel::class.java)
@ -85,7 +86,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
initView() initView()
upScreenTimeOut() upScreenTimeOut()
ReadBook.callBack = this ReadBook.callBack = this
ReadBook.titleDate.observe(this, Observer { title_bar.title = it }) ReadBook.titleDate.observe(this, Observer {
title_bar.title = it
upMenu()
})
viewModel.initData(intent) viewModel.initData(intent)
} }
@ -143,9 +147,18 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.read_book, menu) menuInflater.inflate(R.menu.read_book, menu)
replaceUseMenu = menu.findItem(R.id.menu_enable_replace)
upMenu()
return super.onCompatCreateOptionsMenu(menu) return super.onCompatCreateOptionsMenu(menu)
} }
private fun upMenu() {
ReadBook.book?.let {
replaceUseMenu?.isChecked = it.useReplaceRule
}
}
/** /**
* 菜单 * 菜单
*/ */
@ -222,6 +235,10 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
R.id.menu_update_toc -> ReadBook.book?.let { R.id.menu_update_toc -> ReadBook.book?.let {
viewModel.loadChapterList(it) viewModel.loadChapterList(it)
} }
R.id.menu_enable_replace -> ReadBook.book?.let {
it.useReplaceRule = !it.useReplaceRule
replaceUseMenu?.isChecked = it.useReplaceRule
}
} }
return super.onCompatOptionsItemSelected(item) return super.onCompatOptionsItemSelected(item)
} }
@ -378,7 +395,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
seek_read_page.progress = ReadBook.durPageIndex seek_read_page.progress = ReadBook.durPageIndex
} }
override fun showMenu() { override fun showMenuBar() {
read_menu.runMenuIn() read_menu.runMenuIn()
} }

@ -101,7 +101,7 @@ class ReadAloudDialog : DialogFragment() {
} }
private fun initOnClick() { private fun initOnClick() {
iv_menu.onClick { callBack?.showMenu(); dismiss() } iv_menu.onClick { callBack?.showMenuBar(); dismiss() }
iv_other_config.onClick { iv_other_config.onClick {
ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog") ReadAloudConfigDialog().show(childFragmentManager, "readAloudConfigDialog")
} }
@ -135,7 +135,7 @@ class ReadAloudDialog : DialogFragment() {
} }
interface CallBack { interface CallBack {
fun showMenu() fun showMenuBar()
fun openChapterList() fun openChapterList()
fun onClickReadAloud() fun onClickReadAloud()
fun finish() fun finish()

Loading…
Cancel
Save