package com.abbidot.tracker.adapter

import android.content.Context
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.DataBean
import com.abbidot.tracker.constant.ConstantInt
import com.abbidot.tracker.widget.TypefaceButton

/**
 * 首页地图宠物警告适配器
 */
class HomeMapDeviceMsgAdapter(
    ctx: Context, list: MutableList<DataBean>?
) : BaseRecyclerAdapter<DataBean>(ctx, list) {
    override fun getEmptyLayoutId(viewType: Int) = 0

    override fun getItemLayoutId(viewType: Int) = R.layout.item_home_map_device_msg

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: DataBean) {
        val typefaceTextView = holder!!.getView(R.id.tv_device_msg_content) as TypefaceButton
        typefaceTextView.apply {
            text = item.value
            val colorId = if (item.state == ConstantInt.Type1) R.color.green_color10
            else R.color.device_msg_color1

            setBackgroundColor(ContextCompat.getColor(context, colorId))
        }
    }
}