package fr.plnech.dunbar.ui

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import fr.plnech.dunbar.R
import fr.plnech.dunbar.model.Friend


class FriendsAdapter(
    private var friends: List<Friend> = mutableListOf()
) : RecyclerView.Adapter<FriendsViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FriendsViewHolder =
        FriendsViewHolder(
            LayoutInflater.from(parent.context).inflate(viewType, parent, false)
        )

    override fun getItemCount(): Int = friends.size

    override fun getItemViewType(position: Int): Int = R.layout.contact_listitem

    override fun onBindViewHolder(holder: FriendsViewHolder, position: Int): Unit =
        holder.bind(friends[position])
}