关联用户
This commit is contained in:
@@ -23,6 +23,7 @@ class CustomDialogFragmentText : DialogFragment() {
|
||||
private var positiveText: String = ""
|
||||
private var showInput: Boolean = true
|
||||
private var onConfirmListener: ((String) -> Unit)? = null
|
||||
private var onDismissListener: (() -> Unit)? = null
|
||||
|
||||
fun setTitle(title: String): CustomDialogFragmentText {
|
||||
this.title = title
|
||||
@@ -63,6 +64,10 @@ class CustomDialogFragmentText : DialogFragment() {
|
||||
this.onConfirmListener = listener
|
||||
}
|
||||
|
||||
fun setOnDismissListener(listener: () -> Unit) {
|
||||
this.onDismissListener = listener
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.let {
|
||||
@@ -87,7 +92,6 @@ class CustomDialogFragmentText : DialogFragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
// Set defaults if not explicitly configured
|
||||
if (negativeText.isEmpty()) negativeText = getString(R.string.cancel)
|
||||
if (positiveText.isEmpty()) positiveText = getString(R.string.confirm)
|
||||
binding.tvTitle.text = title
|
||||
@@ -112,6 +116,8 @@ class CustomDialogFragmentText : DialogFragment() {
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
onDismissListener?.invoke()
|
||||
onConfirmListener = null
|
||||
onDismissListener = null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user