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

import android.content.Intent
import android.view.View
import com.abbidot.tracker.R
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.DeviceBean
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.databinding.ActivityDeleteTracker1Binding
import com.abbidot.tracker.util.Util

class DeleteTracker1Activity :
    BaseActivity<ActivityDeleteTracker1Binding>(ActivityDeleteTracker1Binding::inflate) {

    private var mDeviceBean: DeviceBean? = null
    private var isOnlyBindOneDevice = false

    override fun getTopBar() = mViewBinding.ilDeleteTracker1TopBar.titleTopBar

    override fun initData() {
        super.initData()
        setTopBarTitle("")
        setLeftBackImage(R.drawable.icon_white_back_svg)

        intent.extras?.apply {
            isOnlyBindOneDevice = getBoolean(ConstantString.isCheck, false)
            mDeviceBean = Util.getParcelableAdaptive(
                intent, ConstantString.DeviceInfo, DeviceBean::class.java
            )
        }

        mViewBinding.apply {
            setOnClickListenerViews(btnCancelDeleteTracker1, btnNextDeleteTracker1)
        }
    }

    override fun onClick(v: View?) {
        mViewBinding.apply {
            when (v!!) {
                btnCancelDeleteTracker1 -> finish()
                btnNextDeleteTracker1 -> {
                    Intent(mContext, DeleteTracker2Activity::class.java).let {
                        it.putExtra(ConstantString.DeviceInfo, mDeviceBean)
                        it.putExtra(ConstantString.isCheck, isOnlyBindOneDevice)
                        startActivityFinish(it)
                    }
                }
            }
        }
    }
}