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.Material_Scan;

import com.tomas.lps_asi.R;

import java.util.List;

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

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

    public class ViewHolder extends RecyclerView.ViewHolder{
        public LinearLayout layout;
        public TextView txt_material_code, txt_type, txt_lot_no, txt_exp;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            layout = (LinearLayout)itemView.findViewById(R.id.row_item);
            txt_material_code = (TextView)itemView.findViewById(R.id.txt_material_code);
            txt_lot_no = (TextView)itemView.findViewById(R.id.txt_lot_no);
            txt_exp = (TextView)itemView.findViewById(R.id.txt_exp);
            txt_type = (TextView)itemView.findViewById(R.id.txt_type);
        }
    }

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

    @Override
    public void onBindViewHolder(@NonNull TapeMaterial_Adapter.ViewHolder holder, int position) {
        final Material_Scan list = data.get(position);
        holder.txt_material_code.setText(list.getMaterial_code());
        holder.txt_lot_no.setText(list.getMaterial_lot_no());
        holder.txt_exp.setText(list.getMaterial_exp());
        holder.txt_type.setText(list.getMaterial_type());
    }

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