Last active
April 17, 2018 12:33
-
-
Save Audhil/fe6eebc9a3ecc8528b549c9fc347919c to your computer and use it in GitHub Desktop.
AlertDialogs with Extn funcs blog_2
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
abstract class BaseDialogHelper { | |
abstract val dialogView: View | |
abstract val builder: AlertDialog.Builder | |
// required bools | |
open var cancelable: Boolean = true | |
open var isBackGroundTransparent: Boolean = true | |
// dialog | |
open var dialog: AlertDialog? = null | |
// dialog create | |
open fun create(): AlertDialog { | |
dialog = builder | |
.setCancelable(cancelable) | |
.create() | |
// very much needed for customised dialogs | |
if (isBackGroundTransparent) | |
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | |
return dialog!! | |
} | |
// cancel listener | |
open fun onCancelListener(func: () -> Unit): AlertDialog.Builder? = | |
builder.setOnCancelListener { | |
func() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment