Skip to content

Cancelable #5

Description

@crm76

It would be nice to control if it's cancelable. For my needs, I quickly changed show() to return the DialogFragment so I could set isCancelable like so...

val alert = AlertView("Title", "Message", AlertStyle.DIALOG)
var dialog = alert.show(this)
dialog.isCancelable = false


fun show(activity: AppCompatActivity) : android.support.v4.app.DialogFragment {
    var result : android.support.v4.app.DialogFragment

    when (style) {
        AlertStyle.BOTTOM_SHEET -> {
            val bottomSheet = BottomSheetFragment(title, message, actions, style, theme)
            bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
            result = bottomSheet
        }
        AlertStyle.IOS -> {
            val bottomSheet = BottomSheetFragment(title, message, actions, style, theme)
            bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
            result = bottomSheet
        }
        AlertStyle.DIALOG -> {
            val bottomSheet = DialogFragment(title, message, actions, theme)
            bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
            result = bottomSheet
        }
    }
    
    return result
}

Thank you for the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions