,
var onItemClickListener: HomeAdapter.OnItemClickListener?
):RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryItemViewHolder {
var holder=CategoryItemViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_category,parent,false))
return holder
}
override fun getItemCount(): Int=data.size
override fun onBindViewHolder(holder: CategoryItemViewHolder, position: Int) {
holder.setData(data[position] as CategoryData)
holder.itemView.setOnClickListener {
onItemClickListener?.onItemClick(holder.itemView,data[position] as CategoryData)
}
}
class CategoryItemViewHolder( itemView: View): RecyclerView.ViewHolder(itemView) {