Last active
April 17, 2018 10:49
-
-
Save Audhil/31e7165d4428490f42e00263454f35c3 to your computer and use it in GitHub Desktop.
Making custom alert dialogs with Kotlin extension functions
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
/* | |
* Notes Dialog | |
*/ | |
inline fun Activity.showNotesAlertDialog(func: NotesDialogHelper.() -> Unit): AlertDialog = | |
NotesDialogHelper(this).apply { | |
func() | |
}.create() | |
inline fun Fragment.showNotesAlertDialog(func: NotesDialogHelper.() -> Unit): AlertDialog = | |
NotesDialogHelper(this.context!!).apply { | |
func() | |
}.create() | |
/* | |
* TimeChooser Dialog | |
*/ | |
inline fun Activity.showTimeChooserAlertDialog(func: TimeChooserDialogHelper.() -> Unit): AlertDialog = | |
TimeChooserDialogHelper(this).apply { | |
func() | |
}.create() | |
inline fun Fragment.showTimeChooserAlertDialog(func: TimeChooserDialogHelper.() -> Unit): AlertDialog = | |
TimeChooserDialogHelper(this.context!!).apply { | |
func() | |
}.create() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment