pull/1434/head
gedoor 3 years ago
parent 411b99915c
commit f125aa8bc3
  1. 6
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt
  2. 24
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt

@ -10,10 +10,16 @@ class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleV
override val viewModel: TxtTocRuleViewModel by viewModels()
override val binding: ActivityTxtTocRuleBinding by viewBinding(ActivityTxtTocRuleBinding::inflate)
private val adapter: TxtTocRuleAdapter by lazy {
TxtTocRuleAdapter(this)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
TODO("Not yet implemented")
}
private fun initView() {
}
}

@ -10,6 +10,8 @@ import io.legado.app.databinding.ItemTxtTocRuleBinding
class TxtTocRuleAdapter(context: Context) :
RecyclerAdapter<TxtTocRule, ItemTxtTocRuleBinding>(context) {
private val selected = linkedSetOf<TxtTocRule>()
override fun getViewBinding(parent: ViewGroup): ItemTxtTocRuleBinding {
return ItemTxtTocRuleBinding.inflate(inflater, parent, false)
}
@ -25,7 +27,27 @@ class TxtTocRuleAdapter(context: Context) :
}
override fun registerListener(holder: ItemViewHolder, binding: ItemTxtTocRuleBinding) {
TODO("Not yet implemented")
binding.cbSource.setOnCheckedChangeListener { buttonView, isChecked ->
getItem(holder.layoutPosition)?.let {
if (buttonView.isPressed) {
if (isChecked) {
selected.add(it)
} else {
selected.remove(it)
}
}
}
}
binding.swtEnabled.setOnCheckedChangeListener { buttonView, isChecked ->
getItem(holder.layoutPosition)?.let {
if (buttonView.isPressed) {
it.enable = isChecked
}
}
}
binding.ivEdit.setOnClickListener {
}
}
}

@ -110,7 +110,6 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) {
binding.apply {
swtEnabled.setOnCheckedChangeListener { view, checked ->
if (view.isPressed) {
getItem(holder.layoutPosition)?.let {
if (view.isPressed) {
it.enabled = checked
@ -118,9 +117,7 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
}
}
}
}
cbBookSource.setOnCheckedChangeListener { view, checked ->
if (view.isPressed) {
getItem(holder.layoutPosition)?.let {
if (view.isPressed) {
if (checked) {
@ -132,7 +129,6 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
}
}
}
}
ivEdit.setOnClickListener {
getItem(holder.layoutPosition)?.let {
callBack.edit(it)

Loading…
Cancel
Save