Android: Clear listener in SwitchSettingViewHolder

If bind was called more than once for a SwitchSettingViewHolder, the
line `binding.settingSwitch.isChecked = setting.isChecked` would
accidentally trigger the listener registered during the previous bind
call.
This commit is contained in:
JosJuice 2025-06-06 18:46:15 +02:00 committed by LillyJadeKatrin
parent 4f849ec827
commit f8cddf344d

View File

@ -32,6 +32,9 @@ class SwitchSettingViewHolder(
binding.textSettingName.text = item.name binding.textSettingName.text = item.name
binding.textSettingDescription.text = item.description binding.textSettingDescription.text = item.description
// Make sure we don't trigger any listener set earlier
binding.settingSwitch.setOnCheckedChangeListener(null)
binding.settingSwitch.isChecked = setting.isChecked binding.settingSwitch.isChecked = setting.isChecked
binding.settingSwitch.isEnabled = setting.isEditable binding.settingSwitch.isEnabled = setting.isEditable