Commit 515a576b authored by Fabius's avatar Fabius

FIX: #23 Es werden nur noch die Tage angezeigt für die Essen verfügbar ist

parent aa8838de
......@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -89,6 +90,17 @@ public class ExpandableMensaList extends AbstractASiSTFragment {
daten = new ArrayList<String>();
menus = new HashMap<String, List<CanteenMenu>>();
List<CanteenMenu> firstMenuList = new ArrayList<CanteenMenu>();
firstMenuList.addAll(selectedCanteen.getMenuItems());
Date maxDate = Calendar.getInstance().getTime();
for(final CanteenMenu menu : firstMenuList){
Date maxDateTemp = menu.getDate();
if(maxDateTemp.compareTo(maxDate) > 0){
maxDate = maxDateTemp;
}
}
//Adding Daten
for(int i = 0;i < 5;i++){
if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY){
......@@ -99,8 +111,6 @@ public class ExpandableMensaList extends AbstractASiSTFragment {
add(calendar);
}
daten.add(cleanDate(calendar));
List<CanteenMenu> firstMenuList = new ArrayList<CanteenMenu>();
firstMenuList.addAll(selectedCanteen.getMenuItems());
//Sorts for Categorys (Menu 1 should be on top)
Collections.sort(firstMenuList, new Comparator<CanteenMenu>() {
......@@ -122,10 +132,13 @@ public class ExpandableMensaList extends AbstractASiSTFragment {
menuListWithMatchingDates.add(menu);
}
}
firstMenuList.clear();
add(calendar);
menus.put(daten.get(i), menuListWithMatchingDates);
String temp;
temp = cleanDate(calendar);
if(temp.compareTo(cleanDate(maxDate)) > 0) break;
}
firstMenuList.clear();
}
//Calendar goes one Day ahead
......@@ -152,4 +165,9 @@ public class ExpandableMensaList extends AbstractASiSTFragment {
return format.format(cal.getTime());
}
private String cleanDate(Date date){
SimpleDateFormat format = new SimpleDateFormat(DATE_Format);
return format.format(date.getTime());
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment