package com.pennapps.labs.pennmobile.adapters;

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 com.pennapps.labs.pennmobile.classes.DiningHall;
import com.pennapps.labs.pennmobile.R;

import org.apache.commons.lang3.text.WordUtils;

import java.util.ArrayList;

public class DiningAdapter extends ArrayAdapter<DiningHall> {

    public DiningAdapter(Context context, ArrayList<DiningHall> diningHalls) {
        super(context, R.layout.dining_list_item, diningHalls);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        DiningHall diningHall = getItem(position);
        View view = convertView;

        view = LayoutInflater.from(getContext())
                .inflate(R.layout.dining_list_item, null);

        TextView hallNameTV = (TextView) view.findViewById(R.id.dining_hall_name);
        TextView dinnerMenuTV = (TextView) view.findViewById(R.id.dining_hall_dinner);
        TextView lunchMenuTV = (TextView) view.findViewById(R.id.dining_hall_lunch);

        hallNameTV.setText(WordUtils.capitalizeFully(diningHall.getName()));
        dinnerMenuTV.setText("DINNER");
        lunchMenuTV.setText("LUNCH");

        if (diningHall.getLunchMenu() != null) {
            String lunchText = "";
            for (String key : diningHall.getLunchMenu().keySet()) {
                lunchText += key + ": " + diningHall.getLunchMenu().get(key) + "\n";
            }
            lunchMenuTV.setText(lunchText);
        }

        if (diningHall.getDinnerMenu() != null) {
            String dinnerText = "";
            for (String key : diningHall.getDinnerMenu().keySet()) {
                dinnerText += key + ": " + diningHall.getDinnerMenu().get(key) + "\n";
            }
            dinnerMenuTV.setText(dinnerText);
        }

        return view;
    }

}

@@ -407,16 +407,38 @@
 rayList;
+%0Aimport java.util.Map;
 %0A%0Apublic
@@ -1437,34 +1437,58 @@
        for (
-String key
+Map.Entry%3CString, String%3E menuItem
  : diningHal
@@ -1500,26 +1500,28 @@
 LunchMenu().
-k
 e
+ntr
 ySet()) %7B%0A  
@@ -1538,68 +1538,139 @@
     
-lunchText += key + %22: %22 + diningHall.getLunchMenu().get(key)
+String key = menuItem.getKey();%0A                String value = menuItem.getValue();%0A                lunchText += key + %22: %22 + value
  + %22
@@ -1846,26 +1846,50 @@
    for (
-String key
+Map.Entry%3CString, String%3E menuItem
  : dinin
@@ -1910,18 +1910,20 @@
 rMenu().
-k
 e
+ntr
 ySet()) 
@@ -1944,70 +1944,140 @@
     
-dinnerText += key + %22: %22 + diningHall.getDinnerMenu().get(key)
+String key = menuItem.getKey();%0A                String value = menuItem.getValue();%0A                dinnerText += key + %22: %22 + value
  + %22

Refactor hashmap looping code