Fixed the dialog not being actually closed on click outside

Misplaced methods ftw
This commit is contained in:
Viktor De Pasquale 2020-01-06 16:41:44 +01:00
parent baf18a8762
commit 13262fdb18

View File

@ -37,6 +37,7 @@ class MagiskDialog @JvmOverloads constructor(
init { init {
binding.setVariable(BR.data, data) binding.setVariable(BR.data, data)
setCancelable(true)
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -57,10 +58,16 @@ class MagiskDialog @JvmOverloads constructor(
) )
insets insets
} }
}
binding.dialogBaseOutsideContainer.setOnClickListener { override fun setCancelable(flag: Boolean) {
val listener = if (!flag) {
null
} else {
setCanceledOnTouchOutside(true) setCanceledOnTouchOutside(true)
View.OnClickListener { dismiss() }
} }
binding.dialogBaseOutsideContainer.setOnClickListener(listener)
} }
inner class Data { inner class Data {