package com.develop.setting.init.adapter

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.develop.setting.R

class CircleAdapter : BaseQuickAdapter<Int, BaseViewHolder>(R.layout.item_screen_circle) {
    private var selectedPosition = 0
    override fun convert(holder: BaseViewHolder, item: Int) {
        val ivCircle = holder.getView<View>(R.id.iv_circle)
        if (selectedPosition == holder.adapterPosition){
            ivCircle.setBackgroundResource(R.drawable.f4a12e_circle)
        } else {
            ivCircle.setBackgroundResource(R.drawable.e5e5e5_circle)
        }
    }

    fun updateSelectedPosition(adapterPosition: Int) {
        val tempPosition = selectedPosition
        selectedPosition = adapterPosition
        notifyItemChanged(tempPosition)
        notifyItemChanged(selectedPosition)
    }
}