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.BindDeviceXuetangAdapter
import com.zj365.health.vm.BindDeviceListVm

/**
 * 绑定血糖仪列表
 */
@Route(path = ARouterUrl.XUETANGYI_BIND_LIST)
class XuetangDeviceBindListAct : BaseDeviceBindListAct<BindDeviceListVm>() {

    private var userId:String?=null
    private var isMe = false
    override fun initData() {
        super.initData()
        userId = intent.getStringExtra("userId").toString()
        isMe = userId.isNullOrEmpty() || userId == CommonUtils.getMyUserId()
    }

    override fun initAdapter() {
        mAdapter = BindDeviceXuetangAdapter()
        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.XUETANG.type, userId)
    }

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

    override fun goToHistoryList() {
        bundle.clear()
        if (userId.isNullOrEmpty()){
            userId = CommonUtils.getMyUserId()
        }
        bundle.putString("userId",userId)
        bundle.putString(DataManageTypeAct.exceptionKey,"血糖历史记录")
        bundle.putString(DataManageTypeAct.dataType,"${DeviceType.XUETANG.type}")
        RouteManager.goAct(ARouterUrl.BODY_FAT_BIND_CHAT, bundle)
    }
}