package com.cpm.lorealbaMabeline.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.cpm.lorealbaMabeline.R;
import com.cpm.lorealbaMabeline.gsonGetterSetter.MasterInvoiceType;
import java.util.ArrayList;
import java.util.List;


public class InvoiceTypeSpinnerAdapter extends ArrayAdapter<MasterInvoiceType> {
    List<MasterInvoiceType> list;
    Context context;
    int resourceId;

    public InvoiceTypeSpinnerAdapter(Context context, int resourceId, ArrayList<MasterInvoiceType> list) {
        super(context, resourceId, list);
        this.context = context;
        this.list = list;
        this.resourceId = resourceId;
    }

    @SuppressLint("ViewHolder")
    @NonNull
    @Override
    public View getView(int position, View convertView, @NonNull ViewGroup parent) {
        View view = convertView;
        LayoutInflater inflater =(LayoutInflater.from(context));
        view = inflater.inflate(resourceId, parent, false);
        MasterInvoiceType cm = list.get(position);
        TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
        txt_spinner.setText(list.get(position).getInvoiceType());

        return view;
    }

    @Override
    public View getDropDownView(int position, View convertView, @NonNull ViewGroup parent) {
        View view = convertView;
        LayoutInflater inflater = (LayoutInflater.from(context));
        view = inflater.inflate(resourceId, parent, false);
        MasterInvoiceType cm = list.get(position);
        TextView txt_spinner = (TextView) view.findViewById(R.id.txt_sp_text);
        txt_spinner.setText(cm.getInvoiceType());

        return view;
    }

}
