1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-08-25 05:26:40 -05:00

android: Set switch listener before assigning new value

Previously the switch could have its old listener triggered when recycled.
This commit is contained in:
Charles Lombardo
2023-08-12 01:00:42 -04:00
parent 26ff214719
commit 0d4bf53ad9

View File

@@ -25,10 +25,10 @@ class SwitchSettingViewHolder(val binding: ListItemSettingSwitchBinding, adapter
binding.textSettingDescription.text = ""
binding.textSettingDescription.visibility = View.GONE
}
binding.switchWidget.isChecked = setting.isChecked
binding.switchWidget.setOnCheckedChangeListener { _: CompoundButton, _: Boolean ->
adapter.onBooleanClick(item, bindingAdapterPosition, binding.switchWidget.isChecked)
}
binding.switchWidget.isChecked = setting.isChecked
binding.switchWidget.isEnabled = setting.isEditable
}