package com.zj365.health.adapter

import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.tamsiree.rxkit.RxTimeTool
import com.xty.base.adapter.BaseAdapter
import com.zj365.health.R
import com.xty.network.model.DkBean
import com.xty.network.model.ExceptionBean
import java.text.SimpleDateFormat

class ExceptionAdapter : BaseAdapter<ExceptionBean>(R.layout.item_excption_data) {

    override fun convert(holder: BaseViewHolder, item: ExceptionBean) {

        holder.setText(R.id.index, (item.index+1).toString())
        holder.setText(R.id.mInfo, item.data)
        if (item.index == 0) {
            holder.setGone(R.id.index_title, false)
            holder.setGone(R.id.data_title, false)
            holder.setGone(R.id.time_title, false)
        } else {
            holder.setGone(R.id.index_title, true)
            holder.setGone(R.id.data_title, true)
            holder.setGone(R.id.time_title, true)
        }
        holder.setText(
            R.id.mtime, RxTimeTool.milliseconds2String(
                item.time.toLong() * 1000,
                SimpleDateFormat("yyyy-MM-dd HH:mm")
            )
        )
    }
}