@Override
public void onSuccess(Bridge result) {
if (result.meals.size() > 0) {
RootPanel rootPanel = RootPanel.get("UserMeals");
// DecoratorPanel goalDecoratorPanel = new DecoratorPanel();
// rootPanel.add(goalDecoratorPanel);
FlexTable mealsFlexTable = new FlexTable();
// mealsFlexTable.setStyleName("cw-FlexTable");
// mealsFlexTable.setSize("270px", "300px");
mealsFlexTable.setWidth("390px");
mealsFlexTable.setText(0, 0, "Name");
mealsFlexTable.setText(0, 1, "Meal Items");
mealsFlexTable.setText(0, 2, "Calories");
mealsFlexTable.getCellFormatter().addStyleName(0, 0,
"mealsListHeader");
mealsFlexTable.getCellFormatter().addStyleName(0, 1,
"mealsListHeader");
mealsFlexTable.getCellFormatter().addStyleName(0, 2,
"mealsListHeader");
double mealCalToday = 0.0;
int row = 0;
for (Meal meal : result.meals) {
row++;
mealsFlexTable.setText(row, 0, meal.getLabel());
mealsFlexTable.getCellFormatter().addStyleName(row, 0,
"mealsListRow");
String itemTitle = "";
for (FoodItem item : meal.getFoodItems()) {
itemTitle += item.getName() + "</br>";
}
HTML html = new HTML(itemTitle);
mealsFlexTable.setWidget(row, 1, html);
mealsFlexTable.getCellFormatter().addStyleName(row, 1,
"mealsListRow");
mealsFlexTable.setText(row, 2,
String.valueOf(meal.totalCalories()));
mealsFlexTable.getCellFormatter().addStyleName(row, 2,
"mealsListRow");
mealCalToday += meal.totalCalories();
}
Landing.mealCal = mealCalToday;
HTML html = new HTML("</br>Total calories consumed = "
+ (int)mealCalToday);
mealsFlexTable.setWidget(row + 1, 1, html);
mealsFlexTable.getCellFormatter().addStyleName(row + 1, 1,
"mealsTotalCalories");
rootPanel.add(mealsFlexTable);
getUserWorkout();
}
}