package com.sketch.ar.artdrawing.allImageList

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.sketch.ar.artdrawing.databinding.AdapterAllListBinding
import com.sketch.ar.artdrawing.utils.BaseAdapter
import com.sketch.ar.artdrawing.utils.CommonUtils

class AllImageListAdapter(var category:String, context: Context, var clickAction:(filePath:String)->Unit):
    BaseAdapter<String, AdapterAllListBinding>(context) {
    override fun getViewBinding(parent: ViewGroup?): AdapterAllListBinding {

       return  AdapterAllListBinding.inflate(
           LayoutInflater.from(parent?.context),
           parent,
           false
       )
    }


    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val itemHolder  = holder as VHolder<AdapterAllListBinding>
        data[position].let {
            val filePath = "$category/$it"
         CommonUtils.loadImage(mContext, filePath, CommonUtils.dpToPx(60f), CommonUtils.dpToPx(140f)){
             itemHolder.vb.mainImage.setImageBitmap(it)
         }
            itemHolder.vb.mainImage.setOnClickListener {
                clickAction(filePath)
            }
        }


    }


}