package com.zj365.dc.adapter

import android.graphics.drawable.GradientDrawable
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.tamsiree.rxkit.RxTimeTool
import com.xty.base.adapter.BaseAdapter
import com.xty.network.model.MessageBean
import com.zj365.dc.R
import java.text.SimpleDateFormat


class WarningMessageAdapter():BaseAdapter<MessageBean.SysMsg>(R.layout.item_warning_message) {
    override fun convert(holder: BaseViewHolder, item: MessageBean.SysMsg) {
        holder.setText(R.id.mTitle, item.notifyTitle)
            .setText(R.id.mContent,item.notifyContent)
            .setText(R.id.mTvTime,RxTimeTool.milliseconds2String(item.notifyCreateTime, SimpleDateFormat("yyyy-MM-dd HH:mm")))
        changeStatus(holder.getView(R.id.mTitle),item.notifyStatus)
    }

    private fun changeStatus(tv: TextView,status:Int) {
        var draw =ContextCompat.getDrawable(context,R.drawable.shape_msg_status) as GradientDrawable
        if(status==0){
            draw.setColor(ContextCompat.getColor(context,R.color.col_e03))
        }else{
            draw.setColor(ContextCompat.getColor(context,R.color.white))
        }
        draw.mutate()
        draw.setBounds(0,0,draw.minimumWidth,draw.minimumHeight)
        tv.setCompoundDrawables(draw,null,null,null)
    }

}


