add a new field to radio group dialog

This commit is contained in:
tibbi 2017-03-18 17:14:26 +01:00
parent 746d0c5ae5
commit 4c4d65252d
2 changed files with 3 additions and 3 deletions

View file

@ -11,7 +11,7 @@ import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.dialog_radio_group.view.*
import java.util.*
class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>, val checkedItemId: Int, val callback: (newValue: Int) -> Unit) :
class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>, val checkedItemId: Int, val callback: (newValue: Any) -> Unit) :
AlertDialog.Builder(activity), RadioGroup.OnCheckedChangeListener {
val dialog: AlertDialog?
var wasInit = false
@ -40,7 +40,7 @@ class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>,
override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
if (wasInit) {
callback.invoke(items[checkedId].id)
callback.invoke(items[checkedId].value)
dialog?.dismiss()
}
}

View file

@ -1,3 +1,3 @@
package com.simplemobiletools.commons.models
data class RadioItem(val id: Int, val title: String)
data class RadioItem(val id: Int, val title: String, val value: Any = id.toString())