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