feat: 优化代码

pull/133/head
kunfei 5 years ago
parent f6b3fb1b49
commit b791d443bf
  1. 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 7
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt

@ -215,6 +215,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
R.id.menu_enable_replace -> ReadBook.book?.let {
it.useReplaceRule = !it.useReplaceRule
menu?.findItem(R.id.menu_enable_replace)?.isChecked = it.useReplaceRule
onReplaceRuleSave()
}
R.id.menu_book_info -> ReadBook.book?.let {
startActivity<BookInfoActivity>(Pair("bookUrl", it.bookUrl))

@ -141,8 +141,8 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
}
private fun observeReplaceRuleData(key: String? = null) {
replaceRuleLiveData?.removeObservers(this)
dataInit = false
replaceRuleLiveData?.removeObservers(this)
replaceRuleLiveData = if (key.isNullOrEmpty()) {
App.db.replaceRuleDao().liveDataAll()
} else {
@ -304,22 +304,27 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
}
override fun update(vararg rule: ReplaceRule) {
setResult(Activity.RESULT_OK)
viewModel.update(*rule)
}
override fun delete(rule: ReplaceRule) {
setResult(Activity.RESULT_OK)
viewModel.delete(rule)
}
override fun edit(rule: ReplaceRule) {
setResult(Activity.RESULT_OK)
ReplaceEditDialog.show(supportFragmentManager, rule.id)
}
override fun toTop(rule: ReplaceRule) {
setResult(Activity.RESULT_OK)
viewModel.toTop(rule)
}
override fun upOrder() {
setResult(Activity.RESULT_OK)
viewModel.upOrder()
}
}
Loading…
Cancel
Save