package com.module.backstage.dialog

import android.content.Context
import android.view.View
import android.widget.AdapterView
import android.widget.AdapterView.OnItemSelectedListener
import android.widget.ArrayAdapter
import com.module.backstage.R
import com.module.backstage.databinding.BackstageDialogLocalAlarmClockBinding
import com.module.backstage.databinding.BackstageDialogPayGoreSetBinding
import com.quyunshuo.androidbaseframemvvm.base.mvvm.v.BaseFrameDialog
import com.quyunshuo.androidbaseframemvvm.base.utils.SpUtils
import com.quyunshuo.androidbaseframemvvm.common.bean.LocalAlarmClockBean
import com.quyunshuo.androidbaseframemvvm.common.constant.MMKVName
import com.quyunshuo.androidbaseframemvvm.common.enums.AlarmClockEnum
import com.quyunshuo.androidbaseframemvvm.common.enums.WeekEnum
import com.quyunshuo.androidbaseframemvvm.common.util.AmountMoney
import com.quyunshuo.androidbaseframemvvm.common.util.ToastUtil
import com.quyunshuo.androidbaseframemvvm.common.util.XLogUtil
import com.tencent.mmkv.MMKV


/**
 * 支付更多设置的对话框
 */
class PayGoreSetDialog(mContext: Context) :
    BaseFrameDialog<BackstageDialogPayGoreSetBinding>(mContext) {
    private var listener: DialogClickListener? = null
    var add:Int =1
    var update:Int =2
    var id:Int? = 0

    override fun BackstageDialogPayGoreSetBinding.initView() {
        tvBack.setOnClickListener {
            dismiss()
        }
        var language2ArrayAdapter =
            ArrayAdapter<String>(this@PayGoreSetDialog.context, R.layout.spinner_text)
        language2ArrayAdapter.addAll(AmountMoney.language)
        XLogUtil.d("PayGoreSetDialog1:"+SpUtils.getInt(MMKVName.PAPERTYPE,0)!!)
        mBinding.spMultiple.adapter = language2ArrayAdapter
        mBinding.spMultiple.setOnItemSelectedListener(object : OnItemSelectedListener {
            override fun onItemSelected(
                parent: AdapterView<*>?,
                view: View?,
                position: Int,
                id: Long,
            ) {
                SpUtils.putInt(MMKVName.PAPERTYPE, position)
                AmountMoney.earth = AmountMoney.allCurrency()
            }

            override fun onNothingSelected(parent: AdapterView<*>?) {
            }
        })
        mBinding.spMultiple.setSelection(SpUtils.getInt(MMKVName.PAPERTYPE,0)!!)
        if (SpUtils.getBoolean(MMKVName.DIY_PAY,false)!!) {
            rbDiyPayOpen.isChecked = true
        }else{
            rbDiyPayClose.isChecked = true

        }
    }


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


    override fun initObserve() {
    }

    override fun initRequestData() {
    }

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



    interface DialogClickListener {
        fun onClickListener(type: Int, localAlarmClockBean: LocalAlarmClockBean)

    }
}