package com.casic.br.view

import androidx.recyclerview.widget.DividerItemDecoration
import com.casic.br.R
import com.casic.br.adapter.AddedDeviceAdapter
import com.casic.br.model.AddedDeviceModel
import com.gyf.immersionbar.ImmersionBar
import com.pengxh.kt.lite.base.KotlinBaseActivity
import com.pengxh.kt.lite.extensions.convertColor
import com.pengxh.kt.lite.extensions.show
import com.pengxh.kt.lite.utils.ImmerseStatusBarUtil
import kotlinx.android.synthetic.main.fragment_device.*
import kotlinx.android.synthetic.main.include_base_title.*
import java.util.*

class AllDeviceActivity : KotlinBaseActivity() {

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

    override fun setupTopBarLayout() {
        ImmersionBar.with(this).statusBarDarkFont(true).init()
        ImmerseStatusBarUtil.setColor(this, R.color.white.convertColor(this))

        leftBackView.setOnClickListener { finish() }
        titleView.text = "全部设备"
    }

    override fun initData() {
        //TODO 模拟数据
        val deviceModels = ArrayList<AddedDeviceModel>()
        for (i in 0..9) {
            val model = AddedDeviceModel()
            model.deviceName = "*****热水器"
            model.deviceUsedTime = "已使用${Random().nextInt(12)}个月${Random().nextInt(31)}天"

            deviceModels.add(model)
        }
//        val addedDeviceAdapter = AddedDeviceAdapter(this, deviceModels)
//        deviceRecyclerView.addItemDecoration(
//            DividerItemDecoration(this, DividerItemDecoration.VERTICAL)
//        )
//        deviceRecyclerView.adapter = addedDeviceAdapter
//        addedDeviceAdapter.setOnItemClickListener(object :
//            AddedDeviceAdapter.OnItemClickListener {
//            override fun onItemClick(position: Int) {
//                //TODO 需要根据设备类型显示不同的页面
//                val deviceModel = deviceModels[position]
//                deviceModel.deviceName.show(this@AllDeviceActivity)
//            }
//        })
    }

    override fun observeRequestState() {

    }

    override fun initEvent() {

    }
}