package com.abbidot.tracker.adapter

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

/**
 */
class SelectFencesTypeCardShadeAdapter(
    ctx: Context, list: MutableList<DataBean>?
) : BaseRecyclerAdapter<DataBean>(ctx, list) {

    override fun getEmptyLayoutId(viewType: Int) = 0

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: DataBean) {
        val imageView = holder!!.getImageView(R.id.iv_select_type_image)
        imageView.setImageResource(item.imageId)
        val cardView = holder.itemView as CardView
        cardView.apply {
            isSelected = item.selected
            cardElevation = if (item.selected) {
                setCardBackgroundColor(ContextCompat.getColor(context, R.color.select_color))
                QMUIDisplayHelper.dpToPx(4).toFloat()
            } else {
                setCardBackgroundColor(ContextCompat.getColor(context, R.color.transparent))
                0f
            }
        }
    }
}