package com.yidian.bcommon.base

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.viewbinding.ViewBinding
import com.yidian.bcommon.R

/**
 * author: yinjiacheng
 * date: 5/29/21 11:12 AM
 * description: Base Dialog
 */
abstract class BaseDialog<VB : ViewBinding> @JvmOverloads constructor(
    context: Context,
    themeResId: Int = R.style.base_dialog
) :
    Dialog(context, themeResId) {

    lateinit var viewBinding: VB

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        viewBinding = createViewBinding()
        setContentView(viewBinding.root)
        initView()
        initListener()
        init(savedInstanceState)
    }

    abstract fun createViewBinding(): VB

    abstract fun initView()

    abstract fun initListener()

    open fun init(savedInstanceState: Bundle?) {

    }
}
