From d7b73b801b091ab7fe4fe4f5b3b7e74331883e6d Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 22 Oct 2021 15:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=BA=90=E5=92=8C=E8=A7=84?= =?UTF-8?q?=E5=88=99=E6=97=B6=E5=8F=AF=E4=BB=A5=E5=85=88=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=86=8D=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/association/ImportBookSourceDialog.kt | 3 ++- .../app/ui/association/ImportReplaceRuleDialog.kt | 6 ++++-- .../app/ui/association/ImportRssSourceDialog.kt | 3 ++- .../io/legado/app/ui/widget/dialog/CodeDialog.kt | 13 +++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt index 42c8146ea..178818d94 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt @@ -194,7 +194,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie requestId?.toInt()?.let { BookSource.fromJson(code)?.let { source -> viewModel.allSources[it] = source - adapter.notifyItemChanged(it) + adapter.setItem(it, source) } } } @@ -242,6 +242,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie showDialogFragment( CodeDialog( GSON.toJson(source), + disableEdit = false, requestId = holder.layoutPosition.toString() ) ) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt index ce174a793..2d7497616 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt @@ -186,7 +186,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi requestId?.toInt()?.let { GSON.fromJsonObject(code)?.let { rule -> viewModel.allRules[it] = rule - adapter.notifyItemChanged(it) + adapter.setItem(it, rule) } } } @@ -198,6 +198,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi return ItemSourceImportBinding.inflate(inflater, parent, false) } + @SuppressLint("SetTextI18n") override fun convert( holder: ItemViewHolder, binding: ItemSourceImportBinding, @@ -206,7 +207,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi ) { binding.run { cbSourceName.isChecked = viewModel.selectStatus[holder.layoutPosition] - cbSourceName.text = item.name + cbSourceName.text = "${item.name}(${item.group})" val localRule = viewModel.checkRules[holder.layoutPosition] tvSourceState.text = when { localRule == null -> "新增" @@ -237,6 +238,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi showDialogFragment( CodeDialog( GSON.toJson(source), + disableEdit = false, requestId = holder.layoutPosition.toString() ) ) diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index 1477c5005..e9c18979f 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -193,7 +193,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view requestId?.toInt()?.let { RssSource.fromJson(code)?.let { source -> viewModel.allSources[it] = source - adapter.notifyItemChanged(it) + adapter.setItem(it, source) } } } @@ -240,6 +240,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view showDialogFragment( CodeDialog( GSON.toJson(source), + disableEdit = false, requestId = holder.layoutPosition.toString() ) ) diff --git a/app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt b/app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt index 279e5369c..8be9c4bcf 100644 --- a/app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt +++ b/app/src/main/java/io/legado/app/ui/widget/dialog/CodeDialog.kt @@ -9,6 +9,7 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.ui.widget.code.addJsPattern import io.legado.app.ui.widget.code.addJsonPattern import io.legado.app.ui.widget.code.addLegadoPattern +import io.legado.app.utils.applyTint import io.legado.app.utils.disableEdit import io.legado.app.utils.setLayout import io.legado.app.utils.viewbindingdelegate.viewBinding @@ -48,12 +49,16 @@ class CodeDialog() : BaseDialogFragment(R.layout.dialog_code_view) { private fun initMenu() { binding.toolBar.inflateMenu(R.menu.code_edit) + binding.toolBar.menu.applyTint(requireContext()) binding.toolBar.setOnMenuItemClickListener { when (it.itemId) { - R.id.menu_save -> binding.codeView.text?.toString()?.let { code -> - val requestId = arguments?.getString("requestId") - (parentFragment as? Callback)?.onCodeSave(code, requestId) - ?: (activity as? Callback)?.onCodeSave(code, requestId) + R.id.menu_save -> { + binding.codeView.text?.toString()?.let { code -> + val requestId = arguments?.getString("requestId") + (parentFragment as? Callback)?.onCodeSave(code, requestId) + ?: (activity as? Callback)?.onCodeSave(code, requestId) + } + dismiss() } } return@setOnMenuItemClickListener true