From 900aef347f96fee8b7982e8478a101fb86f4f08c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 19 Aug 2020 17:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/replacerule/edit/ReplaceEditDialog.kt | 6 ++++-- .../ui/replacerule/edit/ReplaceEditViewModel.kt | 16 ++++++++++------ build.gradle | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt index 60235a279..6b207cd0b 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt @@ -35,15 +35,17 @@ class ReplaceEditDialog : BaseDialogFragment(), fragmentManager: FragmentManager, id: Long = -1, pattern: String? = null, - isRegex: Boolean = false + isRegex: Boolean = false, + scope: String? = null ) { val dialog = ReplaceEditDialog() val bundle = Bundle() bundle.putLong("id", id) bundle.putString("pattern", pattern) bundle.putBoolean("isRegex", isRegex) + bundle.putString("scope", scope) dialog.arguments = bundle - dialog.show(fragmentManager, "editReplace") + dialog.show(fragmentManager, this::class.simpleName) } } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt index e4a0d443c..1308b64ec 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt @@ -20,12 +20,16 @@ class ReplaceEditViewModel(application: Application) : BaseViewModel(application replaceRuleData.postValue(it) } } else { - bundle.getString("pattern")?.let { pattern -> - val isRegex = bundle.getBoolean("isRegex") - replaceRuleData.postValue( - ReplaceRule(name = pattern, pattern = pattern, isRegex = isRegex) - ) - } + val pattern = bundle.getString("pattern") ?: "" + val isRegex = bundle.getBoolean("isRegex") + val scope = bundle.getString("scope") + val rule = ReplaceRule( + name = pattern, + pattern = pattern, + isRegex = isRegex, + scope = scope + ) + replaceRuleData.postValue(rule) } } } diff --git a/build.gradle b/build.gradle index 13629c5e0..f2d22610f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.72' + ext.kotlin_version = '1.4.0' repositories { google() jcenter()