Cancelable
crm76 opened this issue · comments
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.
You can simply set cancelable:
fun show(activity: AppCompatActivity, cancelable:Boolean) {
when (style) {
AlertStyle.BOTTOM_SHEET -> {
val bottomSheet = BottomSheetFragment(title, message, actions, style, theme)
bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
bottomSheet.isCancelable=cancelable
}
AlertStyle.IOS -> {
val bottomSheet = BottomSheetFragment(title, message, actions, style, theme)
bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
bottomSheet.isCancelable=cancelable
}
AlertStyle.DIALOG -> {
val bottomSheet = DialogFragment(title, message, actions, theme)
bottomSheet.show(activity.supportFragmentManager, bottomSheet.tag)
bottomSheet.isCancelable=cancelable
}
}
}