Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d34b0fb9 authored by tibbi's avatar tibbi
Browse files

allow optionally adding an OK button to the radiogroup dialog

parent fad36128
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.9.6'
        propVersionName = '3.9.7'
        kotlin_version = '1.2.21'
        support_libs = '27.0.2'
    }
+9 −3
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ import kotlinx.android.synthetic.main.dialog_radio_group.view.*
import java.util.*

class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>, val checkedItemId: Int = -1, val titleId: Int = 0,
                       val cancelCallback: (() -> Unit)? = null, val callback: (newValue: Any) -> Unit) : RadioGroup.OnCheckedChangeListener {
                       showOKButton: Boolean = false, val cancelCallback: (() -> Unit)? = null, val callback: (newValue: Any) -> Unit)
    : RadioGroup.OnCheckedChangeListener {
    val dialog: AlertDialog
    var wasInit = false
    var selectedItemId = -1
@@ -37,9 +38,14 @@ class RadioGroupDialog(val activity: Activity, val items: ArrayList<RadioItem>,
            }
        }

        dialog = AlertDialog.Builder(activity)
        val builder = AlertDialog.Builder(activity)
                .setOnCancelListener { cancelCallback?.invoke() }
                .create().apply {

        if (selectedItemId != -1 && showOKButton) {
            builder.setPositiveButton(R.string.ok, { dialog, which -> onCheckedChanged(view.dialog_radio_group, selectedItemId) })
        }

        dialog = builder.create().apply {
            activity.setupDialogStuff(view, this, titleId)
        }