Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MessageDialog
- @Inject
- constructor(
- private val onPositiveButtonClick: () -> Unit,
- private val onNegativeButtonClick: () -> Unit,
- val data: DialogModel,
- ) : BaseDialogFragment() {
- override val blackoutBackground: Boolean = true
- override val dialogPositionBottom: Boolean = true
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
- dialog?.window?.setBackgroundDrawableResource(R.drawable.dialog_parent_background)
- return inflater.inflate(R.layout.message_dialog, container, false).apply {
- ok.setOnClickListener {
- onPositiveButtonClick
- dialog?.cancel()
- }
- cancel.setOnClickListener {
- onNegativeButtonClick
- dialog?.cancel()
- }
- title_dialog.text = data.title
- subtitle_dialog.text = data.message
- ok.text = data.okText
- cancel.text = data.cancelText
- ok.visibility = if ( data.enableOk ) View.VISIBLE else View.GONE
- cancel.visibility = if ( data.enableCancel ) View.VISIBLE else View.GONE
- }
- }
- }
- // In fragment
- private val messageDialog: MessageDialog by lazy {
- MessageDialog({ onPositiveClick() }, { onNegativeClick() }, logoutDialog)
- }
- private fun onPositiveClick() { }
- private fun onNegativeClick() { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement