feat: 优化代码

pull/123/head
kunfei 5 years ago
parent b60ce32c11
commit afc99e13d3
  1. 8
      app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt
  2. 3
      app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditViewModel.kt

@ -23,11 +23,17 @@ class ReplaceEditDialog : DialogFragment(),
companion object { companion object {
fun show(fragmentManager: FragmentManager, id: Long = -1, pattern: String? = null) { fun show(
fragmentManager: FragmentManager,
id: Long = -1,
pattern: String? = null,
isRegex: Boolean = false
) {
val dialog = ReplaceEditDialog() val dialog = ReplaceEditDialog()
val bundle = Bundle() val bundle = Bundle()
bundle.putLong("id", id) bundle.putLong("id", id)
bundle.putString("pattern", pattern) bundle.putString("pattern", pattern)
bundle.putBoolean("isRegex", isRegex)
dialog.arguments = bundle dialog.arguments = bundle
dialog.show(fragmentManager, "editReplace") dialog.show(fragmentManager, "editReplace")
} }

@ -21,8 +21,9 @@ class ReplaceEditViewModel(application: Application) : BaseViewModel(application
} }
} else { } else {
bundle.getString("pattern")?.let { pattern -> bundle.getString("pattern")?.let { pattern ->
val isRegex = bundle.getBoolean("isRegex")
replaceRuleData.postValue( replaceRuleData.postValue(
ReplaceRule(pattern = pattern) ReplaceRule(pattern = pattern, isRegex = isRegex)
) )
} }
} }

Loading…
Cancel
Save