package com.quyunshuo.module.home.dialog

import android.content.Context
import android.os.Handler
import android.view.View
import android.view.View.OnLongClickListener
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.hboxs.serialport.plc.DialogClickListener
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameDialog
import com.quyunshuo.androidbaseframemvvm.common.util.LongClickUtils
import com.quyunshuo.module.home.databinding.BackstageDialogTipsBinding
import com.quyunshuo.module.home.databinding.BackstageDialogWarringBinding

/**
 * 报警 对话框
 */
class WarringDialog(mContext: Context) : BaseFrameDialog<BackstageDialogWarringBinding>(mContext),
    LifecycleObserver {

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


    private var devOnoffDialoglistener: DialogClickListener? = null

    override fun BackstageDialogWarringBinding.initView() {
        LongClickUtils.setLongClick(Handler(),ivWarringImg, 3000,object : OnLongClickListener{
            override fun onLongClick(v: View?): Boolean {
                devOnoffDialoglistener?.onClickListener(type1,null)
                return true
            }

        })
    }

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

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


    override fun initObserve() {
    }

    override fun initRequestData() {
    }

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

    fun setContent(content: String) {
        mBinding.tvWarringtitle.text = content
    }


}