package com.grewe.ilab.firebaseapp;

import android.widget.ArrayAdapter;





import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by Lynne on 2/5/2018.
 */

public class ItemsAdapter extends ArrayAdapter<Item> {
    public ItemsAdapter(Context context, int resource, List<Item> objects) {
        super(context, resource, objects);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.item_layout, parent, false);
        }

        TextView nameTextView = (TextView) convertView.findViewById(R.id.nameTextView);
        TextView quantityTextView = (TextView) convertView.findViewById(R.id.quantityTextView);

        // grabe the current item
        Item item = getItem(position);

        nameTextView.setVisibility(View.VISIBLE);
        nameTextView.setText(item.getName());
        quantityTextView.setText(item.getQuantity());

        return convertView;
    }
}
