package pt.epvc.ambrosioandroid;

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

public class CustomAdapter extends BaseAdapter {

    String nomeBebida[];
    String descricaoBebida[];
    int imagemBebida[];
    LayoutInflater inflater;

    public CustomAdapter(Context context, String nomeBebida[], String descricaoBebida[], int imagemBebida[]){
        this.nomeBebida = nomeBebida;
        this.descricaoBebida = descricaoBebida;
        this.imagemBebida = imagemBebida;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return imagemBebida.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = inflater.inflate(R.layout.list_item, null);
        TextView nomeBebidaTxt = (TextView) convertView.findViewById(R.id.nomeBebida);
        TextView descricaoBebidaTxt = (TextView) convertView.findViewById(R.id.descricaoBebida);
        ImageView imagemBebidaImg = (ImageView) convertView.findViewById(R.id.imagemBebida);

        nomeBebidaTxt.setText(this.nomeBebida[position]);
        descricaoBebidaTxt.setText(this.descricaoBebida[position]);
        imagemBebidaImg.setImageResource(this.imagemBebida[position]);

        return convertView;
    }
}
