1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package com.sambath.kunkhmer.adapter
- import android.view.LayoutInflater
- import android.view.View
- import android.view.ViewGroup
- import android.widget.ImageView
- import android.widget.TextView
- import androidx.recyclerview.widget.RecyclerView
- import com.sambath.kunkhmer.R
- import com.sambath.kunkhmer.config.Config
- import com.sambath.kunkhmer.remote.Highlight
- import com.squareup.picasso.Picasso
- class HighlightNewsAdapter (var cardList: MutableList<Highlight>) : RecyclerView.Adapter<HighlightNewsAdapter.ViewHolder>() {
- class CardViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
- override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
- val itemView = LayoutInflater.from(parent.context)
- .inflate(R.layout.layout_highlight_item_card, parent, false)
- return ViewHolder(itemView)
- }
- override fun onBindViewHolder(holder: ViewHolder, position: Int) {
- val currentItem = cardList[position]
- // Picasso.get()
- // .load(Config.BASE_URL + "/v1/fighter/image/" + currentItem.)
- // .into(holder.imageView);
- holder.dateTextView.text = currentItem.date
- holder.titleTextView.text = currentItem.title
- }
- override fun getItemCount() = cardList.size
- // Holds the views for adding it to image and text
- class ViewHolder(ItemView: View) : RecyclerView.ViewHolder(ItemView) {
- val imageView: ImageView = itemView.findViewById(R.id.imageView)
- val dateTextView: TextView = itemView.findViewById(R.id.dateTextView)
- val titleTextView: TextView = itemView.findViewById(R.id.titleTextView)
- }
- }
|