package com.abbidot.tracker.ui.activity.help

import android.content.Intent
import android.view.View
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.tracker.R
import com.abbidot.tracker.adapter.HowWorkAdapter
import com.abbidot.tracker.base.BaseActivity
import com.abbidot.tracker.bean.MenuTxtBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.constant.ConstantString
import com.abbidot.tracker.databinding.ActivityHowWorkBinding
import com.abbidot.tracker.util.ViewUtil
import com.qmuiteam.qmui.util.QMUIDisplayHelper

class HowWorkActivity : BaseActivity<ActivityHowWorkBinding>(ActivityHowWorkBinding::inflate) {

    private lateinit var mHowWorkAdapter: HowWorkAdapter

    override fun getTopBar() = mViewBinding.ilHowWorkBar.titleTopBar

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

        val menuList = mutableListOf<MenuTxtBean>()
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_power_on_off))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_active_tracker))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_check_tracker_status))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_sleep_mode))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_wifi_zone_home))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.tracker_manage_set_duration))
//        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_tracker_battery_life))
        ViewUtil.instance.addMenuBean(menuList, getString(R.string.txt_create_pet_fence))
        mHowWorkAdapter = HowWorkAdapter(this, menuList).apply {
            setOnItemClickListener(object : BaseRecyclerAdapter.OnItemClickListener {
                override fun onItemClick(itemView: View?, pos: Int) {
                    when (pos) {
                        0 -> startActivity(Intent(mContext, HelpPowerOnOffActivity::class.java))
                        1 -> startActivity(Intent(mContext, HelpActiveTrackerActivity::class.java))
                        2 -> startActivity(Intent(mContext, HelpTrackerStatusActivity::class.java))
                        3 -> {
                            Intent(mContext, HelpTrackerStatusActivity::class.java).let {
                                it.putExtra(ConstantString.Type, ConstantInt.Type1)
                                startActivity(it)
                            }
                        }
                        4 -> {
                            Intent(mContext, HelpTrackerStatusActivity::class.java).let {
                                it.putExtra(ConstantString.Type, ConstantInt.Type2)
                                startActivity(it)
                            }
                        }
                        5 -> {
                            Intent(mContext, HelpTrackerStatusActivity::class.java).let {
                                it.putExtra(ConstantString.Type, ConstantInt.Type3)
                                startActivity(it)
                            }
                        }

                        6 -> startActivity(Intent(mContext, HelpCreatePetFenceActivity::class.java))
                    }
                }
            })
            ViewUtil.instance.setRecyclerViewVerticalLinearLayout(
                mContext, mViewBinding.rvHowWorkList, this, top = QMUIDisplayHelper.dpToPx(4)
            )
        }
    }
}