package com.abbidot.tracker.adapter

import android.content.Context
import android.view.View
import androidx.core.content.ContextCompat
import com.abbidot.baselibrary.constant.ConState
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
import com.abbidot.baselibrary.list.RecyclerViewHolder
import com.abbidot.tracker.R
import com.abbidot.tracker.bean.DeviceBean
import com.abbidot.tracker.util.Util

/**
 *Created  by .yzq on 2025/12/19/周五.
 * @link
 * @description:
 */
class ScanDeviceAdapter(
    ctx: Context, list: MutableList<DeviceBean>?
) : BaseRecyclerAdapter<DeviceBean>(ctx, list) {

    var isConnect = false

    override fun getEmptyLayoutId(viewType: Int) = 0

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: DeviceBean) {
        holder?.let {
            it.getTextView(R.id.tv_add_new_tracker3_device_out_id_item).apply {
                text = item.deviceOutId
                val tColor = if (isConnect) {
                    R.color.line_color1
                } else {
                    R.color.data_black_color
                }
                setTextColor(ContextCompat.getColor(mContext, tColor))
            }

            holder.getView(R.id.ld_add_new_tracker3_connect_state).visibility =
                if (item.conState == ConState.CONNECTING) View.VISIBLE
                else View.GONE
            holder.getImageView(R.id.iv_add_new_tracker3_device_image)
                .setImageResource(Util.getDeviceTypeImage(item.type))
        }
    }
}