package com.zj365.health.adapter.binddevice

import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.zj365.health.R
import com.xty.network.model.BindDevHistoryBean
import java.lang.StringBuilder


class XueyaBindDeviceHistoryAdapter(): BindDeviceHistoryAdapter() {
    override fun convert(holder: BaseViewHolder, item: BindDevHistoryBean) {
        super.convert(holder,item)
        holder.setText(R.id.tvNumInfo,parseJson(item.info))
        holder.setText(R.id.tvNumInfoTitle,"数值（mmHg）")

    }
//    "{\"highDbp\":\"121\",\"lowDbp\":\"72\",\"pul\":\"67\",\"bloodsugar\":\"6.3\"}",
    fun parseJson(data:String):String{
    var builder = StringBuilder()
        var json = org.json.JSONObject(data)
        if (json.has("highDbp")){
            builder.append(json.get("highDbp"))
            builder.append("/")
        }
        if (json.has("lowDbp")){
            builder.append(json.get("lowDbp"))
        }
//        builder.append(" mmHg")
        return builder.toString()
    }
}