package com.zj365.health.act.binddevice

import com.alibaba.android.arouter.facade.annotation.Route
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.util.CommonUtils
import com.zj365.health.act.datamanage.DataManageTypeAct
import com.zj365.health.adapter.binddevice.BindDeviceXueyaAdapter
import com.zj365.health.vm.BindDeviceListVm

/**
 * 绑定血压计列表
 */
@Route(path = ARouterUrl.XUEYAJI_BIND_LIST)
class XueyaDeviceBindListAct : BaseDeviceBindListAct<BindDeviceListVm>() {

    private var userId = ""
    private var isMe= true

    override fun initData() {
        super.initData()
        userId = intent.getStringExtra("userId").toString()
        isMe = userId.isNullOrEmpty() || userId == CommonUtils.getMyUserId()
    }

    override fun initAdapter() {
        mAdapter = BindDeviceXueyaAdapter()
        mAdapter?.isMe =isMe
        super.initAdapter()
    }

    override fun initView() {
        super.initView()
        binding.title.mTvTitle.text = "血压计"
        if (!isMe){
            binding.tvBindDeviceImdiatly.isEnabled = false
        }
    }

    override fun loadData() {
        mViewModel.getBindList(DeviceType.XUEYA.type, userId)
    }

    override fun goToBind() {
        RouteManager.goAct(ARouterUrl.XUEYAJI_BIND, null)
    }

    override fun goToHistoryList() {
        bundle.clear()
        bundle.putString("userId",userId)
        bundle.putString(DataManageTypeAct.exceptionKey,"血压历史记录")
        bundle.putString(DataManageTypeAct.dataType,"${DeviceType.XUEYA.type}")
        RouteManager.goAct(ARouterUrl.BODY_BLOOD_MEASURE_CHAT, bundle)
    }
}