package com.tomas.lps_asi.Adapter;

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

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

import com.tomas.lps_asi.ListData.NG_List;

import com.tomas.lps_asi.R;

import java.util.List;

public class NG_Adapter extends RecyclerView.Adapter<NG_Adapter.ViewHolder> {
    private List<NG_List>data;
    public Context context;

    public NG_Adapter(List<NG_List> data, Context context) {
        this.data = data;
        this.context = context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        public LinearLayout layout,layout_sch_id;
        public TextView txt_name, txt_qty;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            layout = (LinearLayout)itemView.findViewById(R.id.row_item);
            txt_name = (TextView)itemView.findViewById(R.id.txt_name);
            txt_qty = (TextView)itemView.findViewById(R.id.txt_qty);
        }
    }

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

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        final NG_List lists = data.get(position);
        holder.txt_name.setText(lists.getNg_name());
        holder.txt_qty.setText(lists.getNg_qty());

    }

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