package net.huansi.app.hssummarizingboard.dialog

import android.annotation.SuppressLint
import android.content.Context
import baseform.android.huansi.net.baseui.HsCenterPopupView
import baseform.android.huansi.net.util.ShareUtil
import baseform.android.huansi.net.util.ToastUtil
import net.huansi.app.hssummarizingboard.R
import net.huansi.app.hssummarizingboard.databinding.DialogLoginSettingBinding
import net.huansi.app.hssummarizingboard.utils.Constant

@SuppressLint("ViewConstructor", "MissingPermission")
class LoginSettingDialog(context: Context) :
    HsCenterPopupView<DialogLoginSettingBinding>(context) {

    override fun getLayoutId(): Int {
        return R.layout.dialog_login_setting
    }

    override fun initPopupContent() {
        super.initPopupContent()
        initListener()
    }


    private fun initListener() {
        //取消
        binding.btnLSCancel.setOnClickListener {
            dismiss()
        }

        binding.btnLSOK.setOnClickListener {
            if (binding.etDataRefreshTime.text.toString().trim().isEmpty()) {
                ToastUtil.showShortErrorToast("请输入刷新时间")
                return@setOnClickListener
            }
            ShareUtil.putLong(
                Constant.SP_DATA_REFRESH_TIME,
                binding.etDataRefreshTime.text.toString().trim().toLong()
            )
            dismiss()
        }
    }
}