package com.abbidot.tracker.adapter

import android.content.Context
import android.view.View
import coil.load
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.util.ViewUtil

/**
 *Created  by .yzq on 2024/5/30/030.
 * @link
 * @description:
 */
class AssignOptionsAdapter(
    ctx: Context, list: MutableList<DataBean>?
) : BaseRecyclerAdapter<DataBean>(ctx, list) {
    override fun getEmptyLayoutId(viewType: Int) = 0

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

    override fun bindData(holder: RecyclerViewHolder?, position: Int, item: DataBean) {
        val circleImageView = holder!!.getImageView(R.id.il_bottom_sheet_circle_image)
        val wrapImageView = holder.getImageView(R.id.il_bottom_sheet_wrap_image)
        val name = holder.getTextView(R.id.tv_bottom_sheet_name)

        name.text = item.name
        if (position == 0) {
            circleImageView.visibility = View.GONE
            wrapImageView.visibility = View.GONE
        } else {
            //处理设备类型
            if (item.menuType == ConstantInt.SpecialType) {
                wrapImageView.visibility = View.VISIBLE
                circleImageView.visibility = View.GONE
                wrapImageView.load(R.drawable.icon_tracker_device_small)
            } else {
                circleImageView.visibility = View.VISIBLE
                wrapImageView.visibility = View.GONE
                ViewUtil.instance.setPetTypeHead(circleImageView, item.value, item.menuType)
            }
        }
    }
}