From b791d443bf63a937ba9a98516a0738711ec6bc60 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 2 Mar 2020 20:19:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/ReadBookActivity.kt | 1 + .../io/legado/app/ui/replacerule/ReplaceRuleActivity.kt | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 09d29a7f3..0c954dbb0 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -215,6 +215,7 @@ class ReadBookActivity : VMBaseActivity(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(Pair("bookUrl", it.bookUrl)) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index e5be539c5..91f7e7b75 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -141,8 +141,8 @@ class ReplaceRuleActivity : VMBaseActivity(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(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() } } \ No newline at end of file