package com.example.surveillanceapp;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

class MyAdapter extends RecyclerView.Adapter<MyAdapter.HistoryViewHolder> {
    private ArrayList<HistoryList> historyLists;

    public static class HistoryViewHolder extends RecyclerView.ViewHolder {
        public TextView mTextViewLine1;

        public HistoryViewHolder(View itemView) {
            super(itemView);
            mTextViewLine1 = itemView.findViewById(R.id.textview_line1);
        }
    }

    public MyAdapter(ArrayList<HistoryList> historyList) {
        historyLists = historyList;
    }

    @Override
    public HistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.history_item, parent, false);
        HistoryViewHolder hvh = new HistoryViewHolder(v);
        return hvh;
    }

    @Override
    public void onBindViewHolder(HistoryViewHolder holder, int position) {
        HistoryList currentItem = historyLists.get(position);

        holder.mTextViewLine1.setText(currentItem.getLine1());
    }

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