package com.abbidot.tracker.ui.activity.device

import android.content.Intent
import com.abbidot.tracker.R
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.PetBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.databinding.ActivityInitializingDeviceBinding
import com.abbidot.tracker.ui.activity.device.wifi.AddWifiPowerZone1Activity
import com.abbidot.tracker.util.Util

class InitializingDeviceActivity :
    BaseActivity<ActivityInitializingDeviceBinding>(ActivityInitializingDeviceBinding::inflate) {

    private var mPetBean: PetBean? = null
    private var isFirstBind = false
    private var mDeviceType = ConstantInt.Type1

    override fun getTopBar() = null

    override fun initData() {
        super.initData()

        intent.extras?.apply {
            isFirstBind = getBoolean(ConstantString.isFirstBind, false)
            mPetBean = Util.getParcelableAdaptive(intent, ConstantString.Pet, PetBean::class.java)
            mDeviceType = getInt(ConstantString.Type, ConstantInt.Type1)
        }

        mViewBinding.apply {
            val str = if (mDeviceType == ConstantInt.Type2) {
                tvPaySuccessInitDeviceDec.setText(R.string.txt_init_g40_dec)
                ivInitDeviceFlashImage.setImageResource(R.drawable.icon_init_g40_flash_image)
                String.format(getString(R.string.txt_init_device_tip), "1-5")
            } else String.format(getString(R.string.txt_init_device_tip), "15-20")
            tvPaySuccessInitDeviceTip.text = str

            btnPaySuccessInitDeviceNext.setOnClickListener {
                val intent = Intent(mContext, AddWifiPowerZone1Activity::class.java)
                intent.putExtra(ConstantString.Pet, mPetBean)
                intent.putExtra(ConstantString.isFirstBind, isFirstBind)
                startActivityFinish(intent)
            }
        }
    }

    override fun leftBackOnClick() {

    }

}