AzisMM

DoaListAdapter.kt

Sep 30th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.24 KB | None | 0 0
  1. class DoaListAdapter(
  2.     private val listDoa: ArrayList<DoaModel>,
  3.     private val logo: Int
  4. ) :
  5.     RecyclerView.Adapter<DoaListAdapter.ListViewHolder>() {
  6.  
  7.     inner class ListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
  8.         var ivLogoDoa: ImageView = itemView.findViewById(R.id.iv_logo_doa)
  9.         var tvTitleDoa: TextView = itemView.findViewById(R.id.tv_title_doa)
  10.     }
  11.  
  12.     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListViewHolder {
  13.         val view: View = LayoutInflater.from(parent.context)
  14.             .inflate(R.layout.item_row_doa, parent, false)
  15.         return ListViewHolder(view)
  16.     }
  17.  
  18.     override fun getItemCount(): Int {
  19.         return listDoa.size
  20.     }
  21.  
  22.     override fun onBindViewHolder(holder: ListViewHolder, position: Int) {
  23.         val doa = listDoa[position]
  24.  
  25.         holder.tvTitleDoa.text = doa.title
  26.  
  27.         Glide.with(holder.itemView.context)
  28.             .load(logo)
  29.             .into(holder.ivLogoDoa)
  30.  
  31.         holder.itemView.setOnClickListener {
  32.             val intent = Intent(it.context, DetailDoaActivity::class.java)
  33.             intent.putExtra(DetailDoaActivity.EXTRA_DOA, doa)
  34.             it.context.startActivity(intent)
  35.         }
  36.     }
  37.  
  38. }
Add Comment
Please, Sign In to add comment