package com.casic.br.view

import android.util.Log
import com.casic.br.R
import com.casic.br.adapter.DeviceTypeAdapter
import com.casic.br.extensions.initLayoutImmersionBar
import com.casic.br.utils.WebImageViewHelper
import com.gyf.immersionbar.ImmersionBar
import com.pengxh.kt.lite.base.KotlinBaseActivity
import kotlinx.android.synthetic.main.activity_add_no_iot_device.*
import kotlinx.android.synthetic.main.activity_add_no_iot_device.bigImageView
import kotlinx.android.synthetic.main.fragment_smart_home.*
import kotlinx.android.synthetic.main.include_left_back_title.*

/**
 * 添加非IoT设备
 * */
class AddNoIotDeviceActivity : KotlinBaseActivity() {

    private val kTag = "DeviceTypeFragment"
    private val deviceTypes = arrayOf("热水器", "油烟机", "厨灶具", "其他产品")

    override fun initLayoutView(): Int = R.layout.activity_add_no_iot_device

    override fun observeRequestState() {

    }

    override fun setupTopBarLayout() {
        ImmersionBar.with(this).statusBarDarkFont(true).init()
        initLayoutImmersionBar(rootView)
        leftBackView.setOnClickListener { finish() }
        titleView.text = String.format("添加非Iot设备")
    }

    override fun initData() {
        WebImageViewHelper.setImage(bigImageView, "file:///android_res/mipmap/no_iot.jpg")
    }

    override fun initEvent() {
        val deviceTypeAdapter = DeviceTypeAdapter(this, deviceTypes)
        deviceTypeRecyclerView.adapter = deviceTypeAdapter
        deviceTypeAdapter.setOnTypeItemClickListener(object :
            DeviceTypeAdapter.OnTypeItemClickListener {
            override fun onItemClick(position: Int) {
                Log.d(kTag, "onItemClick: ${deviceTypes[position]}")
            }
        })
    }
}