Helpers to create and handle Android alert dialogs in an RxJava workflow.
To use the regular Android dialog from your Activity, call:
new RxAlertDialog.Builder(this)
.title("Title")
.message("Some action is required")
.positiveButton("OK")
.negativeButton("NO")
.neutralButton("LATER")
.show()
.subscribe(new Observer(){
...
})
To use the Support dialog from your Activity, call:
new RxAlertDialogSupport.Builder(this)
.title("Title")
.message("Some action is required")
.positiveButton("OK")
.negativeButton("NO")
.neutralButton("LATER")
.show()
.subscribe(new Observer(){
...
})
You can also call .create(), but you have to call .show() on the dialog, when it comes with the first event.
- When you call
create()orshow(), you get:- For regular Android dialog: one
AlertDialogDialogEventwheregetAlertDialog()gives you the created dialog. - For Support dialog: one
AlertDialogSupportDialogEventwheregetAlertDialog()gives you the created dialog.
- For regular Android dialog: one
- When you click a button on the dialog, you get:
- one
AlertDialogButtonEventwhere.getWhich()tells you which button was pressed. - the
onCompleted()signal right away.
- one
- When you
.dismiss()the dialog, you get:- the
onCompleted()signal right away.
- the
- If you
.unsubscribe()theObservable, then the dialog will be dismissed.