Guruh: 314-17 Bajardi: Ne’matjonov A


var viewHolder: RecyclerView.ViewHolder? = null


Download 1.68 Mb.
bet21/22
Sana08.01.2022
Hajmi1.68 Mb.
#247739
1   ...   14   15   16   17   18   19   20   21   22
Bog'liq
Ne'matjonov Abduvohid

var viewHolder: RecyclerView.ViewHolder? = null


when (viewType) {

TYPE_CATEGORY ->{


viewHolder=CategoryViewHolder(LayoutInflater.from(context).inflate(R.layout.item_category_list,parent,false),onItemClickListener)


}


TYPE_SLIDER->{

viewHolder=SliderViewHolder(LayoutInflater.from(context).inflate(R.layout.item_slider_list,parent,false),onItemClickListener)


}


else->{

viewHolder=NewsViewHolder(LayoutInflater.from(context).inflate(R.layout.item_news_list,parent,false),onItemClickListener)


}


}


return viewHolder

}

override fun getItemCount(): Int {




if (data != null) {


return data!!.size

}else{




return 0

}


}

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {


Log.i("TTTT",getItemViewType(position).toString())




when (getItemViewType(position)) {

TYPE_CATEGORY ->{


(holder as CategoryViewHolder).bindData(data!!.get(position).listData)


}


TYPE_SLIDER->{

(holder as SliderViewHolder).bindData(data!!.get(position).listData)


}



Download 1.68 Mb.

Do'stlaringiz bilan baham:
1   ...   14   15   16   17   18   19   20   21   22




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling