AzisMM

VideoKajian ListAdapter

Nov 16th, 2021
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. class VideoKajianListAdapter (private val listVideoKajian: ArrayList<VideoKajianModel>)
  2. : RecyclerView.Adapter<VideoKajianListAdapter.ListViewHolder>() {
  3.  
  4. inner class ListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
  5. var imgPhoto: ImageView = itemView.findViewById(R.id.iv_item_photo)
  6. var tvChannel: TextView = itemView.findViewById(R.id.tv_channel)
  7. var tvSpeaker: TextView = itemView.findViewById(R.id.tv_speaker)
  8. var tvTitle: TextView = itemView.findViewById(R.id.tv_title)
  9. }
  10.  
  11. override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder {
  12. val view: View = LayoutInflater.from(parent.context)
  13. .inflate(R.layout.item_row_video_kajian, parent, false)
  14. return ListViewHolder(view)
  15. }
  16.  
  17. override fun getItemCount(): Int {
  18. return listVideoKajian.size
  19. }
  20.  
  21. override fun onBindViewHolder(holder: ListViewHolder, position: Int) {
  22. val video = listVideoKajian[position]
  23.  
  24. holder.tvChannel.text = video.channel
  25. holder.tvSpeaker.text = video.speaker
  26. holder.tvTitle.text = video.title
  27.  
  28. Glide.with(holder.itemView.context)
  29. .load(video.thumbnail)
  30. .apply(bitmapTransform(BlurTransformation(10,1)))
  31. .into(holder.imgPhoto)
  32.  
  33. holder.itemView.setOnClickListener {
  34. val intent = Intent(it.context, DetailVideoKajianActivity::class.java)
  35. intent.putExtra(DetailVideoKajianActivity.EXTRA_VIDEO_KAJIAN, video)
  36. it.context.startActivity(intent)
  37. }
  38. }
  39.  
  40. }
Add Comment
Please, Sign In to add comment