package com.nurulwafa.nufakuproject;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class KegiatanSantriAdapter extends RecyclerView.Adapter<KegiatanSantriAdapter.ViewHolder> {
    private List<KegiatanSantri> kegiatanList;
    private Context context;

    public KegiatanSantriAdapter(Context context, List<KegiatanSantri> kegiatanList) {
        this.context = context;
        this.kegiatanList = kegiatanList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_kegiatan_santri, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        KegiatanSantri kegiatan = kegiatanList.get(position);
        holder.tvNamaKegiatan.setText(kegiatan.getNamaKegiatan());
        holder.tvWaktu.setText(kegiatan.getWaktu());
    }

    @Override
    public int getItemCount() {
        return kegiatanList.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvNamaKegiatan, tvWaktu;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvNamaKegiatan = itemView.findViewById(R.id.tvNamaKegiatan);
            tvWaktu = itemView.findViewById(R.id.tvWaktu);
        }
    }
}
