mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Fix crash when pref mapped to RadioGroup is out of bounds
This commit is contained in:
parent
2e5bf2d0de
commit
d14dfaac89
1 changed files with 1 additions and 1 deletions
|
@ -37,7 +37,7 @@ fun CompoundButton.bindToPreference(pref: Preference<Boolean>, block: ((Boolean)
|
|||
* Binds a radio group with a int preference.
|
||||
*/
|
||||
fun RadioGroup.bindToPreference(pref: Preference<Int>, block: (() -> Unit)? = null) {
|
||||
(getChildAt(pref.get()) as RadioButton).isChecked = true
|
||||
(getChildAt(pref.get()) as? RadioButton)?.isChecked = true
|
||||
setOnCheckedChangeListener { _, checkedId ->
|
||||
val index = indexOfChild(findViewById(checkedId))
|
||||
pref.set(index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue