package com.bassbooster.soundeffects.equalizer.view.activity.effects.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bassbooster.soundeffects.equalizer.data.model.EffectsModel
import com.bassbooster.equalizer.databinding.AdapterEffectsBinding

class EffectsAdapter(val context: Context, val list: ArrayList<EffectsModel>, val mListener: OnItemClickListener) : RecyclerView.Adapter<EffectsAdapter.ViewHolder>() {
    var isSelect = 0
    interface OnItemClickListener {
        fun onItemClick(position: Int)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val binding = AdapterEffectsBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return ViewHolder(binding)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
//        if (isSelect == position){
//            holder.mRlView.background = ContextCompat.getDrawable(context,R.drawable.dra_custom_layout_play_select)
//        }else{
//            holder.mRlView.background = ContextCompat.getDrawable(context,R.drawable.dra_custom_layout_play)
//        }
        holder.binding.mTxtName.text = list[position].name
        holder.binding.mImgType.setImageDrawable(list[position].image)
        holder.binding.mLlView.setOnClickListener {
            mListener.onItemClick(position)
        }
    }

    override fun getItemCount(): Int {
        return list.size
    }

    inner class ViewHolder(val binding: AdapterEffectsBinding) : RecyclerView.ViewHolder(binding.root)

}