Last active
April 17, 2018 13:42
-
-
Save Audhil/e677e8adbd2120481da5649c5ec9b799 to your computer and use it in GitHub Desktop.
AlertDialogs with Extn funcs blog_4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeActivity : AppCompatActivity() { | |
private var timeChooserDialog: AlertDialog? = null | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
showDialog() | |
} | |
private fun showDialog() { | |
if (timeChooserDialog == null) | |
//////////////////////////////////////////////////////////////// | |
// making Alert dialog - admire beauty of kotlin | |
//////////////////////////////////////////////////////////////// | |
timeChooserDialog = showTimeChooserAlertDialog { | |
title.text = "Jack and jill" | |
hrPicker.minValue = 0 | |
hrPicker.maxValue = 23 | |
hrPicker.setFormatter { number -> | |
String.format("%02d", number) | |
} | |
minPicker.minValue = 0 | |
minPicker.maxValue = 59 | |
minPicker.setFormatter { number -> | |
String.format("%02d", number) | |
} | |
hrPickerFocusChangeListener { view, isFocused -> | |
showVLog("hrPickerFocusChangeListener numberPicker : onFocusChanged : isFocused : " + isFocused) | |
} | |
hrPickerValueChangeListener { numberPicker, oldValue, newValue -> | |
showVLog("hrPickerValueChangeListener : newValue : $newValue") | |
} | |
minPickerFocusChangeListener { view, isFocused -> | |
showVLog("minPickerFocusChangeListener numberPicker : onFocusChanged : isFocused : " + isFocused) | |
} | |
minPickerValueChangeListener { numberPicker, oldValue, newValue -> | |
showVLog("minPickerValueChangeListener : newValue : $newValue") | |
} | |
okButtonClickListener { | |
showVLog("okButtonClickListener : okButton clicked") | |
} | |
cancelButtonClickListener { | |
showVLog("cancelButtonClickListener : cancelButton clicked") | |
} | |
onCancelListener { | |
"Dialog got canceled!".showToast() | |
} | |
} | |
// showing | |
timeChooserDialog?.show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment