package com.module.backstage.dialog

import android.content.Context
import com.hboxs.serialport.plc.DialogClickListener
import com.module.backstage.R
import com.module.backstage.databinding.BackstageDialogConnectionServerBinding
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameDialog
import com.quyunshuo.androidbaseframemvvm.common.util.ToastUtil
import com.quyunshuo.androidbaseframemvvm.common.util.UiUtil

/**
 * 连接服务器的对话框
 */
class ConnectionServerDialog (mContext: Context) : BaseFrameDialog<BackstageDialogConnectionServerBinding>(mContext) {
    private val TAG = "ConnectionServerDialog"
    private var connectionServerDialoglistener: DialogClickListener? = null

    var type1:Int =1
    var type2:Int =2
    override fun BackstageDialogConnectionServerBinding.initView() {
        tvBack.setOnClickListener {
            dismiss()
        }
        tvConnectionServer.setOnClickListener{
            if ("" == etServerId.text.trim().toString()) {
                ToastUtil.switchToastStyleToWarn(UiUtil.getStringRes(R.string.base_backstage_data_null_tips))
                return@setOnClickListener
            }
            connectionServerDialoglistener?.onClickListener(type1,etServerId.text.trim().toString())
        }

    }

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


    override fun initObserve() {
    }

    override fun initRequestData() {
    }

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


}