package ta1.cis.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import ta1.cis.R
import ta1.cis.model.response.ResponseSingleJadwal
import ta1.cis.model.response.SingleJadwalItem

class SingleJadwalAdapter(var list: List<SingleJadwalItem?>?) : RecyclerView.Adapter<SingleJadwalAdapter.ViewHolder>() {
    class ViewHolder(itemView:View): RecyclerView.ViewHolder(itemView){
        val jam = itemView.findViewById<TextView>(R.id.jam)
        val matkul = itemView.findViewById<TextView>(R.id.matkul)
    }
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): SingleJadwalAdapter.ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.jadwal_footer,parent,false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: SingleJadwalAdapter.ViewHolder, position: Int) {
        val data = list?.get(position)
        holder.jam.text = "${data?.mulaiMatkul} - ${data?.akhirMatkul}"
        holder.matkul.text = data?.namaMatkul
    }

    override fun getItemCount(): Int = list?.size!!
}