Untitled
unknown
plain_text
2 years ago
2.1 kB
6
Indexable
package com.example.storeapp.ui.features.mainfragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.example.storeapp.databinding.ProductsitemBinding import com.example.storeapp.model.data.ProductLists class RecyclreAdapterNewProductsMainFragment ( val productarraylist: List<ProductLists.ProductslistItem>, val clickoneachproduct: clickonproduct ) : RecyclerView.Adapter<RecyclreAdapterNewProductsMainFragment.myViewHolder>() { lateinit var binding: ProductsitemBinding inner class myViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { fun binder(position: Int) { itemView.setOnClickListener { } binding.txtViewNameProductItem.text = productarraylist[position].name binding.txtViewPriceProductItem.text = productarraylist[position].price Glide.with(binding.root) .load(productarraylist[position].images[0].src) .into(binding.imgViewProductItem) binding.imgViewProductItem.setOnClickListener { clickoneachproduct.click(productarraylist[position], adapterPosition) } } } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): myViewHolder { binding = ProductsitemBinding.inflate(LayoutInflater.from(parent.context), parent, false) return myViewHolder(binding.root) } override fun getItemCount(): Int { return productarraylist.size } override fun onBindViewHolder(holder: myViewHolder, position: Int) { holder.binder(position) } override fun getItemViewType(position: Int): Int { //ghati nakardane recyclerview:khilimohem return position } override fun getItemId(position: Int): Long { return position.toLong() } interface clickonproduct { fun click(data: ProductLists.ProductslistItem, adapterPosition: Int) } }
Editor is loading...