package com.zj365.health.adapter

import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.blankj.utilcode.util.ConvertUtils
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.zj365.health.model.ChildInfo

class BodInfoAdapter( ): BaseAdapter<ChildInfo>(R.layout.item_body_info) {
    var listUnit= mutableListOf<String>()


    override fun convert(holder: BaseViewHolder, item: ChildInfo) {
        if(holder.layoutPosition==11){
            holder.setText(R.id.mValue,"")
                .setText(R.id.mName,"")
        }else{
            holder.setText(R.id.mValue,"${item.values }${listUnit[holder.layoutPosition]}")
                .setText(R.id.mName,item.name)

        }
        var linea=holder.getView<LinearLayout>(R.id.mCenter)


        val layoutParams = linea.layoutParams as RelativeLayout.LayoutParams
        if((holder.layoutPosition+1)%4==0){
            layoutParams.marginEnd=0
        }else{
            layoutParams.marginEnd=ConvertUtils.dp2px(1f)
        }
        holder.setGone(R.id.mBottomLin,holder.layoutPosition>7)
    }
}