package com.module.backstage.dialog

import android.content.Context
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.hboxs.serialport.plc.DialogClickListener
import com.module.backstage.databinding.BackstageDialogOkcancelBinding
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameDialog

/**
 * 确定和取消对话框
 */
class OKCancelDialog(mContext: Context) : BaseFrameDialog<BackstageDialogOkcancelBinding>(mContext),
    LifecycleObserver {

    var type1:Int =1
    var type2:Int =2


    private var devOnoffDialoglistener: DialogClickListener? = null

    override fun BackstageDialogOkcancelBinding.initView() {
        tvBack.setOnClickListener {
            dismiss()
            devOnoffDialoglistener?.onClickListener(type2,null)
        }
        tvStartDev.setOnClickListener{
            devOnoffDialoglistener?.onClickListener(type1,null)
        }

    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    override fun dismiss() {
        super.dismiss()
    }

    override fun createVB() = BackstageDialogOkcancelBinding.inflate(layoutInflater)


    override fun initObserve() {
    }

    override fun initRequestData() {
    }

    fun setListener(listener: DialogClickListener) {
        this.devOnoffDialoglistener = listener
    }

    fun setTitle(title :String){
        mBinding.tvTitle.text = title
    }

}