mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
优化
This commit is contained in:
parent
74184c2cd5
commit
f955825ada
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -441,6 +441,8 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
viewModel.reverseRemoveSameTitle()
|
||||
}
|
||||
|
||||
R.id.menu_effective_replaces -> showDialogFragment<EffectiveReplacesDialog>()
|
||||
|
||||
R.id.menu_help -> showReadMenuHelp()
|
||||
}
|
||||
return super.onCompatOptionsItemSelected(item)
|
||||
|
@ -108,6 +108,11 @@
|
||||
android:title="@string/update_toc"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_effective_replaces"
|
||||
android:title="@string/effective_replaces"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_log"
|
||||
android:title="@string/log"
|
||||
|
@ -1121,4 +1121,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1124,4 +1124,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1124,4 +1124,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1120,4 +1120,5 @@ Còn </string>
|
||||
<string name="page_to">Trang tới</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
@ -1121,4 +1121,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >綜合排序</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1123,4 +1123,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >綜合排序</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1123,4 +1123,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">解析示例</string>
|
||||
<string name="bookshelf_px_4" >综合排序</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
@ -1124,4 +1124,5 @@
|
||||
<string name="page_to">页至</string>
|
||||
<string name="result_analyzed">Analyzed</string>
|
||||
<string name="bookshelf_px_4" >Comprehensive</string>
|
||||
<string name="effective_replaces">起效的替换</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user