package com.zj365.health.adapter

import android.widget.ProgressBar
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.WarringBean
import java.lang.Math.abs


class WarringAdapter: BaseAdapter<WarringBean.Disease>(R.layout.item_warring) {
    override fun convert(holder: BaseViewHolder, item: WarringBean.Disease) {

        holder.setText(R.id.mName,item.type)
       var prog= holder.getView<ProgressBar>(R.id.mProgress)
        if(!item.riskData.isNullOrEmpty()){
            var float=item.riskData.toFloat()
            val formattedRisk = "%.1f%%".format(abs(float * 100))
            holder.setText(R.id.mDesc, formattedRisk)
            prog.progress=(abs(float*100)).toInt()
        }
    }
}