Browse Source

API connection for food and drink views

master
Apostolos Fanakis 6 years ago
parent
commit
574ed64d90
  1. 127
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java
  2. 28
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java
  3. 14
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkIngredientsFragment.java
  4. 19
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java
  5. 126
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java
  6. 28
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java
  7. 14
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodIngredientsFragment.java
  8. 19
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java
  9. 5
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
  10. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java
  11. 78
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Drink.java
  12. 77
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Food.java
  13. 13
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java
  14. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java
  15. 8
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java
  16. 2
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java
  17. 7
      UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java

127
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/DrinkActivity.java

@ -2,8 +2,8 @@ package gr.auth.databases.flavours.activities.drink;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Toast; import android.widget.Toast;
@ -11,6 +11,9 @@ import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,25 +31,41 @@ import gr.auth.databases.flavours.activities.drink.fragments.DrinkIngredientsFra
import gr.auth.databases.flavours.activities.drink.fragments.DrinkRatingsFragment; import gr.auth.databases.flavours.activities.drink.fragments.DrinkRatingsFragment;
import gr.auth.databases.flavours.activities.ingredients.IngredientsActivity; import gr.auth.databases.flavours.activities.ingredients.IngredientsActivity;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.model.Drink;
import gr.auth.databases.flavours.model.Ingredient; import gr.auth.databases.flavours.model.Ingredient;
import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM_TYPE; import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM_TYPE;
import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT; import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT;
import static gr.auth.databases.flavours.session.SessionManager.drinksUserViewUrl;
public class DrinkActivity extends BaseActivity { public class DrinkActivity extends BaseActivity {
public static final String BUNDLE_ARG_DRINK = "BUNDLE_ARG_DRINK";
private static final int ADD_INGREDIENT_REQUEST = 911; private static final int ADD_INGREDIENT_REQUEST = 911;
private ItemSummary mDrink;
private Drink drink;
private ArrayList<Ingredient> ingredients = new ArrayList<>();
private ArrayList<ItemRating> ratings = new ArrayList<>();
private ViewPager viewPager; private ViewPager viewPager;
private FloatingActionButton FAB; private FloatingActionButton FAB;
private TabLayout tabLayout;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drink); setContentView(R.layout.activity_drink);
Bundle extras = getIntent().getExtras();
assert extras != null;
mDrink = extras.getParcelable(BUNDLE_ARG_DRINK);
Toolbar toolbar = findViewById(R.id.drink_toolbar); Toolbar toolbar = findViewById(R.id.drink_toolbar);
toolbar.setTitle("White Russian"); toolbar.setTitle(mDrink.getItemName());
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar(); ActionBar actionbar = getSupportActionBar();
if (actionbar != null) { if (actionbar != null) {
@ -90,9 +109,10 @@ public class DrinkActivity extends BaseActivity {
} }
}); });
setupViewPager(viewPager); tabLayout = findViewById(R.id.drink_tabs);
TabLayout tabLayout = findViewById(R.id.drink_tabs);
tabLayout.setupWithViewPager(viewPager); DrinkTask drinkTask = new DrinkTask();
drinkTask.execute();
} }
@Override @Override
@ -129,9 +149,9 @@ public class DrinkActivity extends BaseActivity {
private void setupViewPager(ViewPager viewPager) { private void setupViewPager(ViewPager viewPager) {
RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager()); RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager());
adapter.addFrag(DrinkInfoFragment.newInstance(64), "INFO"); adapter.addFrag(DrinkInfoFragment.newInstance(drink), "INFO");
adapter.addFrag(DrinkIngredientsFragment.newInstance(64), "INGREDIENTS"); adapter.addFrag(DrinkIngredientsFragment.newInstance(ingredients), "INGREDIENTS");
adapter.addFrag(DrinkRatingsFragment.newInstance(64), "RATINGS"); adapter.addFrag(DrinkRatingsFragment.newInstance(ratings), "RATINGS");
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
} }
@ -164,4 +184,95 @@ public class DrinkActivity extends BaseActivity {
return mFragmentTitleList.get(position); return mFragmentTitleList.get(position);
} }
} }
private class DrinkTask extends AsyncTask<Void, Void, Integer> {
private static final String JSON_TAG_DRINK_INFO = "drinkInfo";
private static final String JSON_TAG_DRINK_ID = "drink_id";
private static final String JSON_TAG_DRINK_NAME = "drink_name";
private static final String JSON_TAG_DRINK_DESCRIPTION = "drink_description";
private static final String JSON_TAG_DRINK_AVG_RATING_OBJ = "averageRating";
private static final String JSON_TAG_DRINK_AVG_RATING = "rating_grade__avg";
private static final String JSON_TAG_DRINK_HAS_ALCOHOL = "drinkHasAlcohol";
private static final String JSON_TAG_DRINK_RESTAURANT_NAME = "restaurantName";
private static final String JSON_TAG_DRINK_INGREDIENTS = "ingredients";
private static final String JSON_TAG_DRINK_INGREDIENT_NAME = "ingredient_name";
private static final String JSON_TAG_DRINK_INGREDIENT_HAS_ALCOHOL = "ingredient_has_alcohol";
private static final String JSON_TAG_DRINK_RATINGS = "ratings";
private static final String JSON_TAG_DRINK_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_DRINK_RATING_USERNAME = "username";
private static final String JSON_TAG_DRINK_RATING_TEXT = "rating_text";
private static final String JSON_TAG_DRINK_RATING_DATE = "rating_date";
private static final String JSON_TAG_DRINK_RATING_PORTION_SIZE = "rating_pοrtion_size";
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Void... params) {
String requestUrl = drinksUserViewUrl + mDrink.getId() + "/";
//Builds the request
Request request = new Request.Builder()
.url(requestUrl)
.build();
try {
//Makes request & handles response
Response response = client.newCall(request).execute();
ResponseBody responseBody = response.body();
assert responseBody != null;
String result = responseBody.string();
JSONObject jsonResponse = new JSONObject(result);
JSONObject jsonFoodInfo = jsonResponse.getJSONObject(JSON_TAG_DRINK_INFO);
double avgRestaurantRating = -1;
if (!jsonResponse.getJSONObject(JSON_TAG_DRINK_AVG_RATING_OBJ).isNull(JSON_TAG_DRINK_AVG_RATING)) {
avgRestaurantRating = jsonResponse.getJSONObject(JSON_TAG_DRINK_AVG_RATING_OBJ).getDouble(JSON_TAG_DRINK_AVG_RATING);
}
drink = new Drink(jsonFoodInfo.getInt(JSON_TAG_DRINK_ID),
jsonFoodInfo.getString(JSON_TAG_DRINK_NAME),
jsonResponse.getString(JSON_TAG_DRINK_RESTAURANT_NAME),
jsonFoodInfo.getString(JSON_TAG_DRINK_DESCRIPTION),
jsonResponse.getBoolean(JSON_TAG_DRINK_HAS_ALCOHOL),
avgRestaurantRating);
JSONArray jsonIngredients = jsonResponse.getJSONArray(JSON_TAG_DRINK_INGREDIENTS);
for (int ingredientIndex = 0; ingredientIndex < jsonIngredients.length(); ++ingredientIndex) {
JSONObject ingredient = jsonIngredients.getJSONObject(ingredientIndex);
ingredients.add(new Ingredient(ingredient.getString(JSON_TAG_DRINK_INGREDIENT_NAME),
ingredient.getBoolean(JSON_TAG_DRINK_INGREDIENT_HAS_ALCOHOL)));
}
JSONArray jsonRatings = jsonResponse.getJSONArray(JSON_TAG_DRINK_RATINGS);
for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRatings.getJSONObject(ratingIndex);
ratings.add(new ItemRating(rating.getInt(JSON_TAG_DRINK_RATING_GRADE),
rating.getString(JSON_TAG_DRINK_RATING_USERNAME),
rating.getString(JSON_TAG_DRINK_RATING_TEXT),
rating.getString(JSON_TAG_DRINK_RATING_DATE),
ItemRating.PortionSize.getEnumTypeFromString(
rating.getString(JSON_TAG_DRINK_RATING_PORTION_SIZE))));
}
return 1;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
setupViewPager(viewPager);
tabLayout.setupWithViewPager(viewPager);
}
}
} }

28
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkInfoFragment.java

@ -9,6 +9,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.Drink;
public class DrinkInfoFragment extends Fragment { public class DrinkInfoFragment extends Fragment {
@ -16,14 +17,14 @@ public class DrinkInfoFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String DRINK_ID = "DRINK_ID"; private static final String DRINK_INFO = "DRINK_INFO";
private int drinkId; private Drink drink;
public static DrinkInfoFragment newInstance(int drinkId) { public static DrinkInfoFragment newInstance(Drink drink) {
DrinkInfoFragment fragment = new DrinkInfoFragment(); DrinkInfoFragment fragment = new DrinkInfoFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(DRINK_ID, drinkId); args.putParcelable(DRINK_INFO, drink);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -32,7 +33,7 @@ public class DrinkInfoFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
drinkId = getArguments().getInt(DRINK_ID); drink = getArguments().getParcelable(DRINK_INFO);
} }
@Override @Override
@ -40,13 +41,22 @@ public class DrinkInfoFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.fragment_drink_info, container, false); final View rootView = inflater.inflate(R.layout.fragment_drink_info, container, false);
TextView restaurantServing = rootView.findViewById(R.id.drink_serving_restaurant); TextView restaurantServing = rootView.findViewById(R.id.drink_serving_restaurant);
restaurantServing.setText(getString(R.string.drink_serving_restaurant_placeholder, "Restaurant's name")); restaurantServing.setText(getString(R.string.drink_serving_restaurant_placeholder, drink.getRestaurantName()));
TextView hasAlcohol = rootView.findViewById(R.id.drink_contains_alcohol); TextView hasAlcohol = rootView.findViewById(R.id.drink_contains_alcohol);
hasAlcohol.setText(getString(R.string.drink_has_alcohol_placeholder, "YES")); hasAlcohol.setText(getString(R.string.drink_has_alcohol_placeholder, drink.hasAlcohol() ? "YES" : "NO"));
TextView rating = rootView.findViewById(R.id.drink_rating); TextView rating = rootView.findViewById(R.id.drink_rating);
rating.setText(getString(R.string.drink_rating_placeholder, 4.65)); if (drink.getRating() != -1) {
rating.setText(getString(R.string.drink_rating_placeholder, drink.getRating()));
} else {
rating.setVisibility(View.GONE);
}
TextView description = rootView.findViewById(R.id.drink_description); TextView description = rootView.findViewById(R.id.drink_description);
description.setText("a description"); if (!drink.getDescription().equals("null")) {
description.setText(drink.getDescription());
} else {
description.setVisibility(View.GONE);
}
return rootView; return rootView;
} }
} }

14
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkIngredientsFragment.java

@ -23,14 +23,14 @@ public class DrinkIngredientsFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String DRINK_ID = "DRINK_ID"; private static final String DRINK_INGREDIENTS = "DRINK_INGREDIENTS";
private int drinkId; private ArrayList<Ingredient> ingredients;
public static DrinkIngredientsFragment newInstance(int drinkId) { public static DrinkIngredientsFragment newInstance(ArrayList<Ingredient> ingredients) {
DrinkIngredientsFragment fragment = new DrinkIngredientsFragment(); DrinkIngredientsFragment fragment = new DrinkIngredientsFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(DRINK_ID, drinkId); args.putParcelableArrayList(DRINK_INGREDIENTS, ingredients);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -39,17 +39,13 @@ public class DrinkIngredientsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
drinkId = getArguments().getInt(DRINK_ID); ingredients = getArguments().getParcelableArrayList(DRINK_INGREDIENTS);
} }
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<Ingredient> ingredients = new ArrayList<>();
ingredients.add(new Ingredient("Βότκα", true));
ingredients.add(new Ingredient("Γάλα", false));
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients); IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients);

19
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/drink/fragments/DrinkRatingsFragment.java

@ -23,14 +23,14 @@ public class DrinkRatingsFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String DRINK_ID = "DRINK_ID"; private static final String DRINK_RATINGS = "DRINK_RATINGS";
private int drinkId; private ArrayList<ItemRating> ratings;
public static DrinkRatingsFragment newInstance(int drinkId) { public static DrinkRatingsFragment newInstance(ArrayList<ItemRating> ratings) {
DrinkRatingsFragment fragment = new DrinkRatingsFragment(); DrinkRatingsFragment fragment = new DrinkRatingsFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(DRINK_ID, drinkId); args.putParcelableArrayList(DRINK_RATINGS, ratings);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -39,22 +39,13 @@ public class DrinkRatingsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
drinkId = getArguments().getInt(DRINK_ID); ratings = getArguments().getParcelableArrayList(DRINK_RATINGS);
} }
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<ItemRating> ratings = new ArrayList<>();
ratings.add(new ItemRating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Ανύπαρκτος", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Γαρδένιος ο Stoner", "-", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Μαγκούστα", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Νταλίκας", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new ItemRating(4, "eddie lives inside you", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM));
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings);

126
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/FoodActivity.java

@ -2,6 +2,7 @@ package gr.auth.databases.flavours.activities.food;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -10,6 +11,9 @@ import android.widget.Toast;
import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,25 +31,41 @@ import gr.auth.databases.flavours.activities.food.fragments.FoodIngredientsFragm
import gr.auth.databases.flavours.activities.food.fragments.FoodRatingsFragment; import gr.auth.databases.flavours.activities.food.fragments.FoodRatingsFragment;
import gr.auth.databases.flavours.activities.ingredients.IngredientsActivity; import gr.auth.databases.flavours.activities.ingredients.IngredientsActivity;
import gr.auth.databases.flavours.base.BaseActivity; import gr.auth.databases.flavours.base.BaseActivity;
import gr.auth.databases.flavours.model.Food;
import gr.auth.databases.flavours.model.Ingredient; import gr.auth.databases.flavours.model.Ingredient;
import gr.auth.databases.flavours.model.ItemRating;
import gr.auth.databases.flavours.model.ItemSummary; import gr.auth.databases.flavours.model.ItemSummary;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM_TYPE; import static gr.auth.databases.flavours.activities.RateItemActivity.BUNDLE_RATE_ITEM_TYPE;
import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT; import static gr.auth.databases.flavours.activities.ingredients.IngredientsActivity.INGREDIENT_PICK_RESULT;
import static gr.auth.databases.flavours.session.SessionManager.foodsUserViewUrl;
public class FoodActivity extends BaseActivity { public class FoodActivity extends BaseActivity {
public static final String BUNDLE_ARG_FOOD = "BUNDLE_ARG_FOOD";
private static final int ADD_INGREDIENT_REQUEST = 420; private static final int ADD_INGREDIENT_REQUEST = 420;
private ItemSummary mFood;
private Food food;
private ArrayList<Ingredient> ingredients = new ArrayList<>();
private ArrayList<ItemRating> ratings = new ArrayList<>();
private ViewPager viewPager; private ViewPager viewPager;
private FloatingActionButton FAB; private FloatingActionButton FAB;
private TabLayout tabLayout;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food); setContentView(R.layout.activity_food);
Bundle extras = getIntent().getExtras();
assert extras != null;
mFood = extras.getParcelable(BUNDLE_ARG_FOOD);
Toolbar toolbar = findViewById(R.id.food_toolbar); Toolbar toolbar = findViewById(R.id.food_toolbar);
toolbar.setTitle("Γεμιστά"); toolbar.setTitle(mFood.getItemName());
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar(); ActionBar actionbar = getSupportActionBar();
if (actionbar != null) { if (actionbar != null) {
@ -89,9 +109,10 @@ public class FoodActivity extends BaseActivity {
} }
}); });
setupViewPager(viewPager); tabLayout = findViewById(R.id.food_tabs);
TabLayout tabLayout = findViewById(R.id.food_tabs);
tabLayout.setupWithViewPager(viewPager); FoodTask foodTask = new FoodTask();
foodTask.execute();
} }
@Override @Override
@ -128,9 +149,9 @@ public class FoodActivity extends BaseActivity {
private void setupViewPager(ViewPager viewPager) { private void setupViewPager(ViewPager viewPager) {
RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager()); RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager());
adapter.addFrag(FoodInfoFragment.newInstance(64), "INFO"); adapter.addFrag(FoodInfoFragment.newInstance(food), "INFO");
adapter.addFrag(FoodIngredientsFragment.newInstance(64), "INGREDIENTS"); adapter.addFrag(FoodIngredientsFragment.newInstance(ingredients), "INGREDIENTS");
adapter.addFrag(FoodRatingsFragment.newInstance(64), "RATINGS"); adapter.addFrag(FoodRatingsFragment.newInstance(ratings), "RATINGS");
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
} }
@ -163,4 +184,95 @@ public class FoodActivity extends BaseActivity {
return mFragmentTitleList.get(position); return mFragmentTitleList.get(position);
} }
} }
private class FoodTask extends AsyncTask<Void, Void, Integer> {
private static final String JSON_TAG_FOOD_INFO = "foodInfo";
private static final String JSON_TAG_FOOD_ID = "food_id";
private static final String JSON_TAG_FOOD_NAME = "food_name";
private static final String JSON_TAG_FOOD_DESCRIPTION = "food_description";
private static final String JSON_TAG_FOOD_CALORIES = "food_calories";
private static final String JSON_TAG_FOOD_AVG_RATING_OBJ = "averageRating";
private static final String JSON_TAG_FOOD_AVG_RATING = "rating_grade__avg";
private static final String JSON_TAG_FOOD_RESTAURANT_NAME = "restaurantName";
private static final String JSON_TAG_FOOD_INGREDIENTS = "ingredients";
private static final String JSON_TAG_FOOD_INGREDIENT_NAME = "ingredient_name";
private static final String JSON_TAG_FOOD_INGREDIENT_HAS_ALCOHOL = "ingredient_has_alcohol";
private static final String JSON_TAG_FOOD_RATINGS = "ratings";
private static final String JSON_TAG_FOOD_RATING_GRADE = "rating_grade";
private static final String JSON_TAG_FOOD_RATING_USERNAME = "username";
private static final String JSON_TAG_FOOD_RATING_TEXT = "rating_text";
private static final String JSON_TAG_FOOD_RATING_DATE = "rating_date";
private static final String JSON_TAG_FOOD_RATING_PORTION_SIZE = "rating_pοrtion_size";
@Override
protected void onPreExecute() {
}
@Override
protected Integer doInBackground(Void... params) {
String requestUrl = foodsUserViewUrl + mFood.getId() + "/";
//Builds the request
Request request = new Request.Builder()
.url(requestUrl)
.build();
try {
//Makes request & handles response
Response response = client.newCall(request).execute();
ResponseBody responseBody = response.body();
assert responseBody != null;
String result = responseBody.string();
JSONObject jsonResponse = new JSONObject(result);
JSONObject jsonFoodInfo = jsonResponse.getJSONObject(JSON_TAG_FOOD_INFO);
double avgRestaurantRating = -1;
if (!jsonResponse.getJSONObject(JSON_TAG_FOOD_AVG_RATING_OBJ).isNull(JSON_TAG_FOOD_AVG_RATING)) {
avgRestaurantRating = jsonResponse.getJSONObject(JSON_TAG_FOOD_AVG_RATING_OBJ).getDouble(JSON_TAG_FOOD_AVG_RATING);
}
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),
avgRestaurantRating);
JSONArray jsonIngredients = jsonResponse.getJSONArray(JSON_TAG_FOOD_INGREDIENTS);
for (int ingredientIndex = 0; ingredientIndex < jsonIngredients.length(); ++ingredientIndex) {
JSONObject ingredient = jsonIngredients.getJSONObject(ingredientIndex);
ingredients.add(new Ingredient(ingredient.getString(JSON_TAG_FOOD_INGREDIENT_NAME),
ingredient.getBoolean(JSON_TAG_FOOD_INGREDIENT_HAS_ALCOHOL)));
}
JSONArray jsonRatings = jsonResponse.getJSONArray(JSON_TAG_FOOD_RATINGS);
for (int ratingIndex = 0; ratingIndex < jsonRatings.length(); ++ratingIndex) {
JSONObject rating = jsonRatings.getJSONObject(ratingIndex);
ratings.add(new ItemRating(rating.getInt(JSON_TAG_FOOD_RATING_GRADE),
rating.getString(JSON_TAG_FOOD_RATING_USERNAME),
rating.getString(JSON_TAG_FOOD_RATING_TEXT),
rating.getString(JSON_TAG_FOOD_RATING_DATE),
ItemRating.PortionSize.getEnumTypeFromString(
rating.getString(JSON_TAG_FOOD_RATING_PORTION_SIZE))));
}
return 1;
} catch (Exception e) {
e.printStackTrace();
return 2;
}
}
@Override
protected void onPostExecute(Integer result) {
setupViewPager(viewPager);
tabLayout.setupWithViewPager(viewPager);
}
}
} }

28
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodInfoFragment.java

@ -9,6 +9,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import gr.auth.databases.flavours.R; import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.Food;
public class FoodInfoFragment extends Fragment { public class FoodInfoFragment extends Fragment {
@ -16,14 +17,14 @@ public class FoodInfoFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String FOOD_ID = "FOOD_ID"; private static final String FOOD_INFO = "FOOD_INFO";
private int foodId; private Food food;
public static FoodInfoFragment newInstance(int foodId) { public static FoodInfoFragment newInstance(Food food) {
FoodInfoFragment fragment = new FoodInfoFragment(); FoodInfoFragment fragment = new FoodInfoFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(FOOD_ID, foodId); args.putParcelable(FOOD_INFO, food);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -32,7 +33,7 @@ public class FoodInfoFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
foodId = getArguments().getInt(FOOD_ID); food = getArguments().getParcelable(FOOD_INFO);
} }
@Override @Override
@ -40,13 +41,22 @@ public class FoodInfoFragment extends Fragment {
final View rootView = inflater.inflate(R.layout.fragment_food_info, container, false); final View rootView = inflater.inflate(R.layout.fragment_food_info, container, false);
TextView restaurantServing = rootView.findViewById(R.id.food_serving_restaurant); TextView restaurantServing = rootView.findViewById(R.id.food_serving_restaurant);
restaurantServing.setText(getString(R.string.food_serving_restaurant_placeholder, "Restaurant's name")); restaurantServing.setText(getString(R.string.food_serving_restaurant_placeholder, food.getRestaurantName()));
TextView calories = rootView.findViewById(R.id.food_calories); TextView calories = rootView.findViewById(R.id.food_calories);
calories.setText(getString(R.string.food_calories_placeholder, 500)); calories.setText(getString(R.string.food_calories_placeholder, food.getCalories()));
TextView rating = rootView.findViewById(R.id.food_rating); TextView rating = rootView.findViewById(R.id.food_rating);
rating.setText(getString(R.string.food_rating_placeholder, 4.65)); if (food.getRating() != -1) {
rating.setText(getString(R.string.food_rating_placeholder, food.getRating()));
} else {
rating.setVisibility(View.GONE);
}
TextView description = rootView.findViewById(R.id.food_description); TextView description = rootView.findViewById(R.id.food_description);
description.setText("some awesome description"); if (!food.getDescription().equals("null")) {
description.setText(food.getDescription());
} else {
description.setVisibility(View.GONE);
}
return rootView; return rootView;
} }
} }

14
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodIngredientsFragment.java

@ -23,14 +23,14 @@ public class FoodIngredientsFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String FOOD_ID = "FOOD_ID"; private static final String FOOD_INGREDIENTS = "FOOD_INGREDIENTS";
private int foodId; private ArrayList<Ingredient> ingredients;
public static FoodIngredientsFragment newInstance(int foodId) { public static FoodIngredientsFragment newInstance(ArrayList<Ingredient> ingredients) {
FoodIngredientsFragment fragment = new FoodIngredientsFragment(); FoodIngredientsFragment fragment = new FoodIngredientsFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(FOOD_ID, foodId); args.putParcelableArrayList(FOOD_INGREDIENTS, ingredients);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -39,17 +39,13 @@ public class FoodIngredientsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
foodId = getArguments().getInt(FOOD_ID); ingredients = getArguments().getParcelableArrayList(FOOD_INGREDIENTS);
} }
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<Ingredient> ingredients = new ArrayList<>();
ingredients.add(new Ingredient("Κιμάς", false));
ingredients.add(new Ingredient("Ρύζι", false));
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients); IngredientItemAdapter itemAdapter = new IngredientItemAdapter(context, ingredients);

19
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/food/fragments/FoodRatingsFragment.java

@ -23,14 +23,14 @@ public class FoodRatingsFragment extends Fragment {
// Required empty public constructor // Required empty public constructor
} }
private static final String FOOD_ID = "FOOD_ID"; private static final String FOOD_RATINGS = "FOOD_RATINGS";
private int foodId; private ArrayList<ItemRating> ratings;
public static FoodRatingsFragment newInstance(int foodId) { public static FoodRatingsFragment newInstance(ArrayList<ItemRating> ratings) {
FoodRatingsFragment fragment = new FoodRatingsFragment(); FoodRatingsFragment fragment = new FoodRatingsFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(FOOD_ID, foodId); args.putParcelableArrayList(FOOD_RATINGS, ratings);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -39,22 +39,13 @@ public class FoodRatingsFragment extends Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
assert getArguments() != null; assert getArguments() != null;
foodId = getArguments().getInt(FOOD_ID); ratings = getArguments().getParcelableArrayList(FOOD_RATINGS);
} }
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false); final View rootView = inflater.inflate(R.layout.reusable_recycler_list, container, false);
ArrayList<ItemRating> ratings = new ArrayList<>();
ratings.add(new ItemRating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Ανύπαρκτος", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Γαρδένιος ο Stoner", "-", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(4, "Μαγκούστα", "Μου άρεσε.", "2018-06-08", ItemRating.PortionSize.MEDIUM));
ratings.add(new ItemRating(5, "Νταλίκας", "Τέλειο.", "2018-06-08", ItemRating.PortionSize.BIG));
ratings.add(new ItemRating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
ratings.add(new ItemRating(4, "eddie lives inside you", "-", "2018-06-08", ItemRating.PortionSize.MEDIUM));
Context context = getContext(); Context context = getContext();
assert context != null; assert context != null;
ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings); ItemRatingsAdapter itemAdapter = new ItemRatingsAdapter(context, ratings);

5
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java

@ -43,6 +43,8 @@ import okhttp3.ResponseBody;
import static gr.auth.databases.flavours.activities.AddItemActivity.BUNDLE_ADD_ITEM_ITEM_TYPE; import static gr.auth.databases.flavours.activities.AddItemActivity.BUNDLE_ADD_ITEM_ITEM_TYPE;
import static gr.auth.databases.flavours.activities.RateRestaurantActivity.BUNDLE_RATE_RESTAURANT; import static gr.auth.databases.flavours.activities.RateRestaurantActivity.BUNDLE_RATE_RESTAURANT;
import static gr.auth.databases.flavours.activities.drink.DrinkActivity.BUNDLE_ARG_DRINK;
import static gr.auth.databases.flavours.activities.food.FoodActivity.BUNDLE_ARG_FOOD;
import static gr.auth.databases.flavours.session.SessionManager.restaurantsUserViewUrl; import static gr.auth.databases.flavours.session.SessionManager.restaurantsUserViewUrl;
public class RestaurantActivity extends BaseActivity public class RestaurantActivity extends BaseActivity
@ -150,12 +152,14 @@ public class RestaurantActivity extends BaseActivity
@Override @Override
public void onRestaurantFoodsFragmentInteraction(ItemSummary item) { public void onRestaurantFoodsFragmentInteraction(ItemSummary item) {
Intent intent = new Intent(this, FoodActivity.class); Intent intent = new Intent(this, FoodActivity.class);
intent.putExtra(BUNDLE_ARG_FOOD, item);
startActivity(intent); startActivity(intent);
} }
@Override @Override
public void onRestaurantDrinksFragmentInteraction(ItemSummary item) { public void onRestaurantDrinksFragmentInteraction(ItemSummary item) {
Intent intent = new Intent(this, DrinkActivity.class); Intent intent = new Intent(this, DrinkActivity.class);
intent.putExtra(BUNDLE_ARG_DRINK, item);
startActivity(intent); startActivity(intent);
} }
@ -208,7 +212,6 @@ public class RestaurantActivity extends BaseActivity
private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening"; private static final String JSON_TAG_RESTAURANT_OPENING = "restaurant_opening";
private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing"; private static final String JSON_TAG_RESTAURANT_CLOSING = "restaurant_closing";
private static final String JSON_TAG_RESTAURANT_AVG_RATING_OBJ = "averageRating"; private static final String JSON_TAG_RESTAURANT_AVG_RATING_OBJ = "averageRating";
private static final String JSON_TAG_RESTAURANT_AVG_RATING = "rating_grade__avg"; private static final String JSON_TAG_RESTAURANT_AVG_RATING = "rating_grade__avg";
private static final String JSON_TAG_RESTAURANT_RATINGS_PER_DIET = "avgRatingPerDiet"; private static final String JSON_TAG_RESTAURANT_RATINGS_PER_DIET = "avgRatingPerDiet";

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java

@ -60,7 +60,7 @@ public class RestaurantItemAdapter extends RecyclerView.Adapter<RecyclerView.Vie
} }
}); });
itemViewHolder.item.setText(item.getItem()); itemViewHolder.item.setText(item.getItemName());
} }
@Override @Override

78
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Drink.java

@ -0,0 +1,78 @@
package gr.auth.databases.flavours.model;
import android.os.Parcel;
import android.os.Parcelable;
public class Drink implements Parcelable {
private int id;
private String name, restaurantName, description;
private boolean hasAlcohol;
private double rating;
public Drink(int id, String name, String restaurantName, String description, boolean hasAlcohol, double rating) {
this.id = id;
this.name = name;
this.restaurantName = restaurantName;
this.description = description;
this.hasAlcohol = hasAlcohol;
this.rating = rating;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getRestaurantName() {
return restaurantName;
}
public String getDescription() {
return description;
}
public boolean hasAlcohol() {
return hasAlcohol;
}
public double getRating() {
return rating;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(id);
out.writeString(name);
out.writeString(restaurantName);
out.writeString(description);
out.writeByte((byte) (hasAlcohol ? 1 : 0));
out.writeDouble(rating);
}
public static final Parcelable.Creator<Drink> CREATOR = new Parcelable.Creator<Drink>() {
public Drink createFromParcel(Parcel in) {
return new Drink(in);
}
public Drink[] newArray(int size) {
return new Drink[size];
}
};
private Drink(Parcel in) {
id = in.readInt();
name = in.readString();
restaurantName = in.readString();
description = in.readString();
hasAlcohol = in.readByte() != 0;
rating = in.readDouble();
}
}

77
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Food.java

@ -0,0 +1,77 @@
package gr.auth.databases.flavours.model;
import android.os.Parcel;
import android.os.Parcelable;
public class Food implements Parcelable {
private int id, calories;
private String name, restaurantName, description;
private double rating;
public Food(int id, String name, String restaurantName, String description, int calories, double rating) {
this.id = id;
this.name = name;
this.restaurantName = restaurantName;
this.description = description;
this.calories = calories;
this.rating = rating;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getRestaurantName() {
return restaurantName;
}
public String getDescription() {
return description;
}
public int getCalories() {
return calories;
}
public double getRating() {
return rating;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeInt(id);
out.writeString(name);
out.writeString(restaurantName);
out.writeString(description);
out.writeInt(calories);
out.writeDouble(rating);
}
public static final Parcelable.Creator<Food> CREATOR = new Parcelable.Creator<Food>() {
public Food createFromParcel(Parcel in) {
return new Food(in);
}
public Food[] newArray(int size) {
return new Food[size];
}
};
private Food(Parcel in) {
id = in.readInt();
name = in.readString();
restaurantName = in.readString();
description = in.readString();
calories = in.readInt();
rating = in.readDouble();
}
}

13
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemRating.java

@ -42,6 +42,19 @@ public class ItemRating extends Rating {
return UNSUPPORTED; return UNSUPPORTED;
} }
} }
public static PortionSize getEnumTypeFromString(String possible) {
switch (possible.toLowerCase()) {
case "small":
return SMALL;
case "medium":
return MEDIUM;
case "big":
return BIG;
default:
return UNSUPPORTED;
}
}
} }
private PortionSize portionSize; private PortionSize portionSize;

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java

@ -53,7 +53,7 @@ public class ItemSummary implements Parcelable {
this.type = type; this.type = type;
} }
public String getItem() { public String getItemName() {
return itemName; return itemName;
} }

8
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/Rating.java

@ -37,10 +37,10 @@ public class Rating implements Parcelable {
@Override @Override
public void writeToParcel(Parcel out, int flags) { public void writeToParcel(Parcel out, int flags) {
out.writeInt(getGrade()); out.writeInt(grade);
out.writeString(getUsername()); out.writeString(username);
out.writeString(getText()); out.writeString(text);
out.writeString(getDate()); out.writeString(date);
} }
public static final Parcelable.Creator<Rating> CREATOR = new Parcelable.Creator<Rating>() { public static final Parcelable.Creator<Rating> CREATOR = new Parcelable.Creator<Rating>() {

2
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/session/SessionManager.java

@ -57,6 +57,8 @@ public class SessionManager {
public static final String restaurantsUserViewUrl = baseServerUrl + "api/restaurantUserView/"; public static final String restaurantsUserViewUrl = baseServerUrl + "api/restaurantUserView/";
public static final String getUserDietsUrl = baseServerUrl + "api/userDiets/"; public static final String getUserDietsUrl = baseServerUrl + "api/userDiets/";
public static final String rateRestaurantUrl = baseServerUrl + "api/userratesrestaurant/"; public static final String rateRestaurantUrl = baseServerUrl + "api/userratesrestaurant/";
public static final String foodsUserViewUrl = baseServerUrl + "api/foodUserView/";
public static final String drinksUserViewUrl = baseServerUrl + "api/drinkUserView/";
// Client & Cookies // Client & Cookies
private final OkHttpClient client; private final OkHttpClient client;

7
UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/utils/ItemRatingsAdapter.java

@ -47,7 +47,12 @@ public class ItemRatingsAdapter extends RecyclerView.Adapter<ItemRatingsAdapter.
holder.portionSize.setVisibility(View.GONE); holder.portionSize.setVisibility(View.GONE);
} }
holder.text.setText(ratings.get(position).getText()); if (!ratings.get(position).getText().equals("null")) {
holder.text.setVisibility(View.VISIBLE);
holder.text.setText(ratings.get(position).getText());
} else {
holder.text.setVisibility(View.GONE);
}
} }
@Override @Override

Loading…
Cancel
Save