package io.zetaphase.chewsnap;

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

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Dave Ho on 3/7/2017.
 */

public class MealAdapter extends ArrayAdapter<Meal>{
    private Context context;
    private List<Meal> mealList;


    public MealAdapter(Context context, int resource, ArrayList<Meal> meals){
        super(context, resource, meals);
        this.context = context;
        this.mealList = meals;
    }

    public View getView(int position, View convertView, ViewGroup parent){
        Meal meal = mealList.get(position);

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(MainActivity.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.meal_row, null);

        TextView title = (TextView) view.findViewById(R.id.mealTitle);
        TextView description = (TextView) view.findViewById(R.id.mealDescription);
        RatingBar rating = (RatingBar) view.findViewById(R.id.mealRating);

        title.setText(meal.getTitle());
        description.setText(meal.getDescription());
        rating.setRating(meal.getNumStars());

        return view;
    }
}

@@ -1348,11 +1348,179 @@
 w;%0A    %7D
+%0A%0A    public List%3CMeal%3E getMealList()%7B%0A        return mealList;%0A    %7D%0A%0A    public void updateMealList(ArrayList%3CMeal%3E mealList)%7B%0A        this.mealList = mealList;%0A    %7D
 %0A%7D%0A

add getset for mealadapter meallissst