|
@@ -0,0 +1,67 @@
|
|
|
|
|
+package io.legado.app.ui.book.read
|
|
|
|
|
+
|
|
|
|
|
+import android.content.Context
|
|
|
|
|
+import android.os.Bundle
|
|
|
|
|
+import android.view.View
|
|
|
|
|
+import android.view.ViewGroup
|
|
|
|
|
+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.ItemTextBinding
|
|
|
|
|
+import io.legado.app.lib.theme.primaryColor
|
|
|
|
|
+import io.legado.app.model.ReadBook
|
|
|
|
|
+import io.legado.app.utils.setLayout
|
|
|
|
|
+import io.legado.app.utils.viewbindingdelegate.viewBinding
|
|
|
|
|
+
|
|
|
|
|
+class EffectiveReplacesDialog : BaseDialogFragment(R.layout.dialog_recycler_view) {
|
|
|
|
|
+
|
|
|
|
|
+ private val binding by viewBinding(DialogRecyclerViewBinding::bind)
|
|
|
|
|
+ private val adapter by lazy { ReplaceAdapter(requireContext()) }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onStart() {
|
|
|
|
|
+ super.onStart()
|
|
|
|
|
+ setLayout(0.9f, ViewGroup.LayoutParams.WRAP_CONTENT)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
+ binding.run {
|
|
|
|
|
+ toolBar.setBackgroundColor(primaryColor)
|
|
|
|
|
+ toolBar.setTitle(R.string.effective_replaces)
|
|
|
|
|
+ recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
|
|
|
|
+ recyclerView.adapter = adapter
|
|
|
|
|
+ }
|
|
|
|
|
+ ReadBook.curTextChapter?.effectiveReplaceRules?.let {
|
|
|
|
|
+ adapter.setItems(it)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private inner class ReplaceAdapter(context: Context) :
|
|
|
|
|
+ RecyclerAdapter<ReplaceRule, ItemTextBinding>(context) {
|
|
|
|
|
+
|
|
|
|
|
+ override fun getViewBinding(parent: ViewGroup): ItemTextBinding {
|
|
|
|
|
+ return ItemTextBinding.inflate(inflater, parent, false)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun registerListener(holder: ItemViewHolder, binding: ItemTextBinding) {
|
|
|
|
|
+ binding.root.setOnClickListener {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ override fun convert(
|
|
|
|
|
+ holder: ItemViewHolder,
|
|
|
|
|
+ binding: ItemTextBinding,
|
|
|
|
|
+ item: ReplaceRule,
|
|
|
|
|
+ payloads: MutableList<Any>
|
|
|
|
|
+ ) {
|
|
|
|
|
+ binding.textView.text = item.name
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|