From 7925c11b42f43fca7674bbe21f0f852dadb3582f Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 13 Jan 2019 19:26:40 +0200 Subject: [PATCH] Minor fixes --- .../databases/flavours/activities/food/FoodActivity.java | 4 +++- .../activities/food/fragments/FoodInfoFragment.java | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java index 03a5ea7..9311733 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java @@ -240,11 +240,13 @@ public class FoodActivity extends BaseActivity { avgRestaurantRating = jsonResponse.getJSONObject(JSON_TAG_FOOD_AVG_RATING_OBJ).getDouble(JSON_TAG_FOOD_AVG_RATING); } + String foodCaloriesString = jsonFoodInfo.getString(JSON_TAG_FOOD_CALORIES); + food = new Food(jsonFoodInfo.getInt(JSON_TAG_FOOD_ID), jsonFoodInfo.getString(JSON_TAG_FOOD_NAME), jsonResponse.getString(JSON_TAG_FOOD_RESTAURANT_NAME), jsonFoodInfo.getString(JSON_TAG_FOOD_DESCRIPTION), - jsonFoodInfo.getInt(JSON_TAG_FOOD_CALORIES), + foodCaloriesString.equals("null") ? -1 : Integer.parseInt(foodCaloriesString), avgRestaurantRating); JSONArray jsonIngredients = jsonResponse.getJSONArray(JSON_TAG_FOOD_INGREDIENTS); diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java index 76c41db..bb74e60 100644 --- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java +++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java @@ -43,7 +43,11 @@ public class FoodInfoFragment extends Fragment { TextView restaurantServing = rootView.findViewById(R.id.food_serving_restaurant); restaurantServing.setText(getString(R.string.food_serving_restaurant_placeholder, food.getRestaurantName())); TextView calories = rootView.findViewById(R.id.food_calories); - calories.setText(getString(R.string.food_calories_placeholder, food.getCalories())); + if (food.getCalories() != -1) { + calories.setText(getString(R.string.food_calories_placeholder, food.getCalories())); + } else { + calories.setVisibility(View.GONE); + } TextView rating = rootView.findViewById(R.id.food_rating); if (food.getRating() != -1) { rating.setText(getString(R.string.food_rating_placeholder, food.getRating()));