package com.zj365.health.adapter.binddevice

import android.view.View
import android.widget.ImageView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.BodyFatHistoryBean

class BodyFatBindDeviceHistoryAdapter :
    BaseAdapter<BodyFatHistoryBean>(R.layout.item_body_fat_history) {

    var isSelect = false
    override fun convert(holder: BaseViewHolder, item: BodyFatHistoryBean) {

        val selectView = holder.getView<ImageView>(R.id.ivSelected)

        if (isSelect) {
            selectView.visibility = View.VISIBLE
            selectView.isSelected = item.isSelect
        } else {
            item.isSelect = false
            selectView.visibility = View.GONE
            selectView.isSelected = false
        }

        holder.setText(R.id.tvOrderNo, "序号: ${getItemPosition(item) + 1}")
        holder.setText(R.id.tvWeight, "体重: ${item.weight}kg")
        holder.setText(R.id.tvHeight, "身高: ${item.height}cm")
        holder.setText(R.id.tvUploadTime, "上传时间: ${item.createTime}")
        if (item.pbf == null || item.pbf == 0.0) {
            holder.setVisible(R.id.tvBodyFat,false)
        } else {
            holder.setGone(R.id.tvBodyFat,false)
            holder.setText(R.id.tvBodyFat,"体脂率: ${item.pbf}%")
        }

    }
}