package com.xw.common.base
|
|
import android.app.Dialog
|
import android.content.Context
|
import android.view.LayoutInflater
|
import androidx.databinding.DataBindingUtil
|
import androidx.databinding.ViewDataBinding
|
|
abstract class BaseDialog<T : ViewDataBinding>(mContext: Context, themeResId: Int = 0) : Dialog(mContext, themeResId) {
|
var binding: T? = null
|
|
abstract fun getLayoutId(): Int
|
abstract fun initData()
|
|
init {
|
if (getLayoutId() > 0) {
|
val view = LayoutInflater.from(mContext).inflate(getLayoutId(), null)
|
with(view) {
|
setContentView(this)
|
binding = DataBindingUtil.bind(this)
|
initData()
|
}
|
|
} else {
|
throw NullPointerException("未设置layout")
|
}
|
}
|
}
|