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()));