package com.zj365.mime.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.network.model.EtFenceListBean
import com.zj365.mime.R

class ElectronicFenceAdapter : BaseAdapter<EtFenceListBean.EtFenceChildBean> (R.layout.item_electron_setting){
    override fun convert(holder: BaseViewHolder, item: EtFenceListBean.EtFenceChildBean) {
        holder.setText(R.id.tv_address,item.title)
        holder.setText(R.id.tv_radius,"半径：${item.radius}米")
        var tvForbid = holder.getView<TextView>(R.id.tv_forbid)

        if (item.type == 1){
            var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_enter)
            tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null)
            tvForbid.compoundDrawablePadding = 5
            tvForbid.text = "禁入"
            tvForbid.setTextColor(Color.parseColor("#F04D42"))

        }else{
            var drawableLeft = context.getDrawable(R.mipmap.icon_forbid_leave)
            tvForbid.setCompoundDrawablesWithIntrinsicBounds(drawableLeft,null,null,null)
            tvForbid.compoundDrawablePadding = 5
            tvForbid.text = "禁出"
            tvForbid.setTextColor(Color.parseColor("#F09C42"))


        }
    }
}