package com.abbidot.tracker.adapter

import android.content.Context
import androidx.cardview.widget.CardView
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.qmuiteam.qmui.util.QMUIDisplayHelper

/**
 *围栏类型
 */
class VirtualFencesZoneShadeAdapter(
    ctx: Context, list: MutableList<DataBean>?
) : BaseRecyclerAdapter<DataBean>(ctx, list) {

    override fun getEmptyLayoutId(viewType: Int) = 0

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: DataBean) {
        val imageView = holder!!.getImageView(R.id.iv_item_shadow_image_view)
        val cardView = holder.itemView as CardView

        if (item.selected) {
            imageView.setImageResource(item.selectImageId)
            cardView.cardElevation = QMUIDisplayHelper.dpToPx(4).toFloat()
        } else {
            imageView.setImageResource(item.imageId)
            cardView.cardElevation = 0f
        }
    }
}