Skip to content

Latest commit

 

History

History
46 lines (40 loc) · 1.42 KB

README.md

File metadata and controls

46 lines (40 loc) · 1.42 KB

rx-alert-dialog

Helpers to create and handle Android alert dialogs in an RxJava workflow.

Usage

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.

Events

  1. When you call create() or show(), you get:
    • For regular Android dialog: one AlertDialogDialogEvent where getAlertDialog() gives you the created dialog.
    • For Support dialog: one AlertDialogSupportDialogEvent where getAlertDialog() gives you the created dialog.
  2. When you click a button on the dialog, you get:
    • one AlertDialogButtonEvent where .getWhich() tells you which button was pressed.
    • the onCompleted() signal right away.
  3. When you .dismiss() the dialog, you get:
    • the onCompleted() signal right away.
  4. If you .unsubscribe() the Observable, then the dialog will be dismissed.