DialogFragment with DataBinding in Kotlin

DialogFragment with DataBinding in Kotlin

class ProfileImageDialog : DialogFragment() {

val viewModel = ProfileImageDialogViewModel()

private val disposables = CompositeDisposable()

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val binding: DialogProfileImageBinding = DataBindingUtil.inflate(LayoutInflater.from(activity), R.layout.dialog_profile_image, null, false)
disposables.add(viewModel.getDismissDialogObservable()
.subscribe{
dismiss()
})
binding.dialogViewModel = viewModel
val dialog = AlertDialog.Builder(activity as Context).setView(binding.root).create()
dialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
return dialog
}

override fun onDestroy() {
super.onDestroy()
disposables.dispose()
}

}

“DialogFragment with DataBinding in Kotlin” Posted first on ” Android on Medium “
Author: 廖浩帆

Author: Pawan Kumar

Leave a Reply

Close Menu
%d bloggers like this:
Skip to toolbar