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 new file mode 100644 index 000000000..03cda5066 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt @@ -0,0 +1,71 @@ +package io.legado.app.ui.association + +import android.content.Context +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.viewModels +import androidx.recyclerview.widget.LinearLayoutManager +import io.legado.app.R +import io.legado.app.base.BaseDialogFragment +import io.legado.app.base.adapter.ItemViewHolder +import io.legado.app.base.adapter.RecyclerAdapter +import io.legado.app.data.entities.ReplaceRule +import io.legado.app.databinding.DialogRecyclerViewBinding +import io.legado.app.databinding.ItemSourceImportBinding +import io.legado.app.utils.viewbindingdelegate.viewBinding + +class ImportReplaceRuleDialog : BaseDialogFragment() { + + private val binding by viewBinding(DialogRecyclerViewBinding::bind) + private val viewModel by viewModels() + lateinit var adapter: SourcesAdapter + + override fun onStart() { + super.onStart() + dialog?.window?.setLayout( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.dialog_recycler_view, container) + } + + override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { + binding.toolBar.setTitle(R.string.import_replace_rule) + adapter = SourcesAdapter(requireContext()) + binding.recyclerView.layoutManager = LinearLayoutManager(requireContext()) + binding.recyclerView.adapter = adapter + adapter.setItems(viewModel.allRules) + } + + inner class SourcesAdapter(context: Context) : + RecyclerAdapter(context) { + + override fun getViewBinding(parent: ViewGroup): ItemSourceImportBinding { + return ItemSourceImportBinding.inflate(inflater, parent, false) + } + + override fun convert( + holder: ItemViewHolder, + binding: ItemSourceImportBinding, + item: ReplaceRule, + payloads: MutableList + ) { + TODO("Not yet implemented") + } + + override fun registerListener(holder: ItemViewHolder, binding: ItemSourceImportBinding) { + TODO("Not yet implemented") + } + + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleViewModel.kt index 8d6da537e..4dba9c35d 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleViewModel.kt @@ -14,7 +14,9 @@ class ImportReplaceRuleViewModel(app: Application) : BaseViewModel(app) { val errorLiveData = MutableLiveData() val successLiveData = MutableLiveData>() - private val allRules = arrayListOf() + val allRules = arrayListOf() + val checkRules = arrayListOf() + val selectStatus = arrayListOf() fun import(text: String) { execute { @@ -32,7 +34,16 @@ class ImportReplaceRuleViewModel(app: Application) : BaseViewModel(app) { }.onError { errorLiveData.postValue(it.localizedMessage ?: "ERROR") }.onSuccess { + comparisonSource() successLiveData.postValue(allRules) } } + + private fun comparisonSource() { + execute { + allRules.forEach { + + } + } + } } \ No newline at end of file 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 6a7c9b844..67cf3b348 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 @@ -37,7 +37,7 @@ import io.legado.app.utils.visible class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { private val binding by viewBinding(DialogRecyclerViewBinding::bind) - val viewModel: ImportRssSourceViewModel by activityViewModels() + private val viewModel by activityViewModels() lateinit var adapter: SourcesAdapter override fun onStart() { diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 18283fdb8..359674384 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -234,7 +234,7 @@ Descripción: sin introducción Abrir libro externo Origen: %s - Importar reglas locales + Importar reglas replace Importar reglas en línea Intervalo de actualizaciones Lista de recientes diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 961d104c5..7ae49bac5 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -234,7 +234,7 @@ Description: no introduction Open external book Origin: %s - Import local rules + Import replace rules Import online rules Check interval for updates By recent list diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index efde516ba..6bb5db968 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -234,7 +234,7 @@ Descrição: sem introdução Abrir o livro externo Origem: %s - Importar regras locais + Import replace rule Importar regras on-line Intervalo de atualizações Lista de recentes diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 05c592dc2..0aaccd421 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -231,7 +231,7 @@ 簡介: 暫無簡介 打開外部書籍 來源: %s - 本地導入 + 導入替換規則 導入在線規則 檢查更新間隔 按閲讀時間 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b781f4ee1..e042521bc 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -233,7 +233,7 @@ 簡介: 暫無簡介 打開外部書籍 來源: %s - 本機匯入 + 匯入替換規則 匯入線上規則 檢查更新間隔 按閱讀時間 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 509525cbc..321411476 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -233,7 +233,7 @@ 简介: 暂无简介 打开外部书籍 来源: %s - 本地导入 + 导入替换规则 导入在线规则 检查更新间隔 按阅读时间 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 722ac6550..b3c6e628f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,7 +234,7 @@ Description: no introduction Open external book Origin: %s - Import local rules + Import replace rules Import online rules Check interval for updates By recent list