package com.module.backstage.dialog

import android.content.Context
import android.os.Build
import com.hboxs.serialport.plc.DialogClickListener
import com.module.backstage.databinding.BackstageDialogTimepickerBinding
import com.module.backstage.model.ApkInfoBean
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameDialog


/**
 * 本地闹钟app的对话框
 */
class TimePickerDialog(mContext: Context) :
    BaseFrameDialog<BackstageDialogTimepickerBinding>(mContext) {
    private var connectionServerDialoglistener: DialogClickListener? = null
    var type1: Int = 1
    var type2: Int = 2
    var hourOfDay = 0
    var minute = 0

    override fun BackstageDialogTimepickerBinding.initView() {
        tvBack.setOnClickListener {
            dismiss()
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            hourOfDay = tpTime.hour
            minute = tpTime.minute
        }
        tpTime.setOnTimeChangedListener { view, hourOfDay, minute ->
            this@TimePickerDialog.hourOfDay = hourOfDay
            this@TimePickerDialog.minute = minute
        }
        tvConfirm.setOnClickListener {
            if (minute < 10) {
                connectionServerDialoglistener?.onClickListener(
                    200,
                    hourOfDay.toString() + ":0" + minute
                )
            } else {
                connectionServerDialoglistener?.onClickListener(
                    200,
                    hourOfDay.toString() + ":" + minute
                )
            }
            dismiss()
        }
    }

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


    override fun initObserve() {
    }

    override fun initRequestData() {
    }

    fun setContent(apkInfoBean: ApkInfoBean?) {

    }

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

    fun setUpdateProgress(progress: Int) {
    }


}