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. 26
      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 viewModel: TxtTocRuleViewModel by viewModels()
override val binding: ActivityTxtTocRuleBinding by viewBinding(ActivityTxtTocRuleBinding::inflate) override val binding: ActivityTxtTocRuleBinding by viewBinding(ActivityTxtTocRuleBinding::inflate)
private val adapter: TxtTocRuleAdapter by lazy {
TxtTocRuleAdapter(this)
}
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
private fun initView() {
}
} }

@ -10,6 +10,8 @@ import io.legado.app.databinding.ItemTxtTocRuleBinding
class TxtTocRuleAdapter(context: Context) : class TxtTocRuleAdapter(context: Context) :
RecyclerAdapter<TxtTocRule, ItemTxtTocRuleBinding>(context) { RecyclerAdapter<TxtTocRule, ItemTxtTocRuleBinding>(context) {
private val selected = linkedSetOf<TxtTocRule>()
override fun getViewBinding(parent: ViewGroup): ItemTxtTocRuleBinding { override fun getViewBinding(parent: ViewGroup): ItemTxtTocRuleBinding {
return ItemTxtTocRuleBinding.inflate(inflater, parent, false) return ItemTxtTocRuleBinding.inflate(inflater, parent, false)
} }
@ -25,7 +27,27 @@ class TxtTocRuleAdapter(context: Context) :
} }
override fun registerListener(holder: ItemViewHolder, binding: ItemTxtTocRuleBinding) { 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,26 +110,22 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) :
override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) { override fun registerListener(holder: ItemViewHolder, binding: ItemBookSourceBinding) {
binding.apply { binding.apply {
swtEnabled.setOnCheckedChangeListener { view, checked -> swtEnabled.setOnCheckedChangeListener { view, checked ->
if (view.isPressed) { getItem(holder.layoutPosition)?.let {
getItem(holder.layoutPosition)?.let { if (view.isPressed) {
if (view.isPressed) { it.enabled = checked
it.enabled = checked callBack.update(it)
callBack.update(it)
}
} }
} }
} }
cbBookSource.setOnCheckedChangeListener { view, checked -> cbBookSource.setOnCheckedChangeListener { view, checked ->
if (view.isPressed) { getItem(holder.layoutPosition)?.let {
getItem(holder.layoutPosition)?.let { if (view.isPressed) {
if (view.isPressed) { if (checked) {
if (checked) { selected.add(it)
selected.add(it) } else {
} else { selected.remove(it)
selected.remove(it)
}
callBack.upCountView()
} }
callBack.upCountView()
} }
} }
} }

Loading…
Cancel
Save