diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
index a36e51b..8542a75 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/AndroidManifest.xml
@@ -46,7 +46,7 @@
android:name=".activities.main.MainActivity"
android:label="@string/main_activity_title" />
-
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddRestaurantActivity.java
similarity index 99%
rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java
rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddRestaurantActivity.java
index 2b47800..e5ea4e8 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/AddRestaurantActivity.java
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/AddRestaurantActivity.java
@@ -1,8 +1,7 @@
-package gr.auth.databases.flavours.activities.restaurant;
+package gr.auth.databases.flavours.activities;
import android.annotation.SuppressLint;
import android.os.Bundle;
-import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
index e011eb7..1dd9c98 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/main/MainActivity.java
@@ -6,6 +6,8 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
@@ -15,7 +17,7 @@ import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import gr.auth.databases.flavours.R;
-import gr.auth.databases.flavours.activities.restaurant.AddRestaurantActivity;
+import gr.auth.databases.flavours.activities.AddRestaurantActivity;
import gr.auth.databases.flavours.activities.main.fragments.MainListFragment;
import gr.auth.databases.flavours.activities.main.fragments.MainMapFragment;
import gr.auth.databases.flavours.base.BaseActivity;
@@ -25,6 +27,7 @@ public class MainActivity extends BaseActivity {
private ViewPager viewPager;
private MenuItem menuMapItem;
+ private FloatingActionButton FAB;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,6 +45,15 @@ public class MainActivity extends BaseActivity {
createDrawer();
+ FAB = findViewById(R.id.main_fab);
+ FAB.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class);
+ startActivity(intent);
+ }
+ });
+
viewPager = findViewById(R.id.main_pager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
@@ -57,20 +69,14 @@ public class MainActivity extends BaseActivity {
if (position == 0) {
menuMapItem.setIcon(R.drawable.ic_map_black_24dp);
+ FAB.show();
} else {
menuMapItem.setIcon(R.drawable.ic_list_black_24dp);
+ FAB.hide();
}
}
});
- findViewById(R.id.main_fab).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class);
- startActivity(intent);
- }
- });
-
PagerAdapter pagerAdapter = new MainPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter);
}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
index 926e5b9..48ce4fd 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantActivity.java
@@ -5,24 +5,31 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentStatePagerAdapter;
-import androidx.viewpager.widget.PagerAdapter;
+import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import gr.auth.databases.flavours.R;
-import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantListFragment;
-import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantMapFragment;
+import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantDrinksFragment;
+import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantFoodsFragment;
+import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantInfoFragment;
+import gr.auth.databases.flavours.activities.restaurant.fragments.RestaurantRatingsFragment;
import gr.auth.databases.flavours.base.BaseActivity;
+import gr.auth.databases.flavours.model.ItemSummary;
import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
-public class RestaurantActivity extends BaseActivity {
- private static final int NUM_PAGES = 2;
+import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import com.google.android.material.tabs.TabLayout;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class RestaurantActivity extends BaseActivity
+ implements RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener,
+ RestaurantDrinksFragment.RestaurantDrinksFragmentInteractionListener {
private ViewPager viewPager;
- private MenuItem menuMapItem;
+ private FloatingActionButton FAB;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -41,6 +48,16 @@ public class RestaurantActivity extends BaseActivity {
createDrawer();
drawer.setSelection(-1);
+ FAB = findViewById(R.id.restaurant_fab);
+ FAB.hide();
+ FAB.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class);
+ startActivity(intent);*/
+ }
+ });
+
viewPager = findViewById(R.id.restaurant_pager);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
@@ -50,85 +67,86 @@ public class RestaurantActivity extends BaseActivity {
}
public void onPageSelected(int position) {
- if (menuMapItem == null) {
- return;
- }
-
if (position == 0) {
- menuMapItem.setIcon(R.drawable.ic_map_black_24dp);
+ FAB.hide();
} else {
- menuMapItem.setIcon(R.drawable.ic_list_black_24dp);
+ FAB.show();
}
}
});
- findViewById(R.id.restaurant_fab).setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- /*Intent intent = new Intent(view.getContext(), AddRestaurantActivity.class);
- startActivity(intent);*/
- }
- });
-
- PagerAdapter pagerAdapter = new RestaurantPagerAdapter(getSupportFragmentManager());
- viewPager.setAdapter(pagerAdapter);
+ setupViewPager(viewPager);
+ TabLayout tabLayout = findViewById(R.id.restaurant_tabs);
+ tabLayout.setupWithViewPager(viewPager);
}
+ /*@Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+
+ if (id == android.R.id.home) {
+ drawer.openDrawer();
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }*/
+
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen()) {
drawer.closeDrawer();
- } else if (viewPager.getCurrentItem() == 1) {
- viewPager.setCurrentItem(0);
} else {
super.onBackPressed();
}
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.restaurant_toolbar_menu, menu);
- menuMapItem = menu.findItem(R.id.restaurant_toolbar_menu_map);
- return true;
+ public void onRestaurantFoodsFragmentInteraction(ItemSummary item) {
+ // todo
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
-
- if (id == R.id.main_toolbar_menu_map) {
- if (viewPager.getCurrentItem() == 0) {
- viewPager.setCurrentItem(1);
- } else if (viewPager.getCurrentItem() == 1) {
- viewPager.setCurrentItem(0);
- }
- return true;
- } else if (id == android.R.id.home) {
- drawer.openDrawer();
- return true;
- }
+ public void onRestaurantDrinksFragmentInteraction(ItemSummary item) {
+ // todo
+ }
- return super.onOptionsItemSelected(item);
+ private void setupViewPager(ViewPager viewPager) {
+ RestaurantPagerAdapter adapter = new RestaurantPagerAdapter(getSupportFragmentManager());
+ adapter.addFrag(RestaurantInfoFragment.newInstance(64), "INFO");
+ adapter.addFrag(RestaurantFoodsFragment.newInstance(64), "FOOD");
+ adapter.addFrag(RestaurantDrinksFragment.newInstance(64), "DRINKS");
+ adapter.addFrag(RestaurantRatingsFragment.newInstance(64), "RATINGS");
+ viewPager.setAdapter(adapter);
}
- private class RestaurantPagerAdapter extends FragmentStatePagerAdapter {
- RestaurantPagerAdapter(FragmentManager fm) {
- super(fm);
+ private class RestaurantPagerAdapter extends FragmentPagerAdapter {
+ private final List mFragmentList = new ArrayList<>();
+ private final List mFragmentTitleList = new ArrayList<>();
+
+ RestaurantPagerAdapter(FragmentManager manager) {
+ super(manager);
}
@NonNull
@Override
public Fragment getItem(int position) {
- if (position == 0) {
- return new RestaurantListFragment();
- } else {
- return new RestaurantMapFragment();
- }
+ return mFragmentList.get(position);
}
@Override
public int getCount() {
- return NUM_PAGES;
+ return mFragmentList.size();
+ }
+
+ void addFrag(Fragment fragment, String title) {
+ mFragmentList.add(fragment);
+ mFragmentTitleList.add(title);
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ return mFragmentTitleList.get(position);
}
}
}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java
new file mode 100644
index 0000000..c60d91a
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantDrinksFragment.java
@@ -0,0 +1,67 @@
+package gr.auth.databases.flavours.activities.restaurant.fragments;
+
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.base.BaseFragment;
+import gr.auth.databases.flavours.model.ItemSummary;
+
+public class RestaurantDrinksFragment extends BaseFragment {
+
+ public RestaurantDrinksFragment() {
+ // Required empty public constructor
+ }
+
+ private static final String RESTAURANT_ID = "RESTAURANT_ID";
+
+ private int restaurantId;
+
+ public static RestaurantDrinksFragment newInstance(int restaurantId) {
+ RestaurantDrinksFragment fragment = new RestaurantDrinksFragment();
+ Bundle args = new Bundle();
+ args.putInt(RESTAURANT_ID, restaurantId);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ assert getArguments() != null;
+ restaurantId = getArguments().getInt(RESTAURANT_ID);
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final View rootView = inflater.inflate(R.layout.fragment_restaurant_items, container, false);
+
+ ArrayList drinks = new ArrayList<>();
+ drinks.add(new ItemSummary("White russian", ItemSummary.ItemType.DRINK));
+ drinks.add(new ItemSummary("Τσίπουρο Τσάπουρας", ItemSummary.ItemType.DRINK));
+
+ RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, drinks);
+ RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list);
+ mainContent.setAdapter(itemAdapter);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
+ mainContent.setLayoutManager(layoutManager);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
+ layoutManager.getOrientation());
+ mainContent.addItemDecoration(dividerItemDecoration);
+
+ return rootView;
+ }
+
+ public interface RestaurantDrinksFragmentInteractionListener extends FragmentInteractionListener {
+ void onRestaurantDrinksFragmentInteraction(ItemSummary foodSummary);
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java
new file mode 100644
index 0000000..170ad83
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantFoodsFragment.java
@@ -0,0 +1,66 @@
+package gr.auth.databases.flavours.activities.restaurant.fragments;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.base.BaseFragment;
+import gr.auth.databases.flavours.model.ItemSummary;
+
+public class RestaurantFoodsFragment extends BaseFragment {
+
+ public RestaurantFoodsFragment() {
+ // Required empty public constructor
+ }
+
+ private static final String RESTAURANT_ID = "RESTAURANT_ID";
+
+ private int restaurantId;
+
+ public static RestaurantFoodsFragment newInstance(int restaurantId) {
+ RestaurantFoodsFragment fragment = new RestaurantFoodsFragment();
+ Bundle args = new Bundle();
+ args.putInt(RESTAURANT_ID, restaurantId);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ assert getArguments() != null;
+ restaurantId = getArguments().getInt(RESTAURANT_ID);
+ }
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final View rootView = inflater.inflate(R.layout.fragment_restaurant_items, container, false);
+
+ ArrayList foods = new ArrayList<>();
+ foods.add(new ItemSummary("Γιουβαρλάκια", ItemSummary.ItemType.FOOD));
+ foods.add(new ItemSummary("Γεμιστά", ItemSummary.ItemType.FOOD));
+
+ RestaurantItemAdapter itemAdapter = new RestaurantItemAdapter(fragmentInteractionListener, foods);
+ RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list);
+ mainContent.setAdapter(itemAdapter);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
+ mainContent.setLayoutManager(layoutManager);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
+ layoutManager.getOrientation());
+ mainContent.addItemDecoration(dividerItemDecoration);
+
+ return rootView;
+ }
+
+ public interface RestaurantFoodsFragmentInteractionListener extends FragmentInteractionListener {
+ void onRestaurantFoodsFragmentInteraction(ItemSummary foodSummary);
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java
similarity index 52%
rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java
rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java
index d6acb57..8e769ae 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantMapFragment.java
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantInfoFragment.java
@@ -1,30 +1,69 @@
package gr.auth.databases.flavours.activities.restaurant.fragments;
-
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.TextView;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.base.BaseFragment;
-public class RestaurantMapFragment extends Fragment implements OnMapReadyCallback {
+public class RestaurantInfoFragment extends BaseFragment implements OnMapReadyCallback {
private MapView gMapView = null;
+ public RestaurantInfoFragment() {
+ // Required empty public constructor
+ }
+
+ private static final String RESTAURANT_ID = "RESTAURANT_ID";
+
+ private int restaurantId;
+
+ public static RestaurantInfoFragment newInstance(int restaurantId) {
+ RestaurantInfoFragment fragment = new RestaurantInfoFragment();
+ Bundle args = new Bundle();
+ args.putInt(RESTAURANT_ID, restaurantId);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ assert getArguments() != null;
+ restaurantId = getArguments().getInt(RESTAURANT_ID);
+ }
+
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_restaurant_map, container, false);
+ final View rootView = inflater.inflate(R.layout.fragment_restaurant_info, container, false);
+
+ TextView workingHours = rootView.findViewById(R.id.restaurant_working_hours);
+ workingHours.setText(getString(R.string.restaurant_working_hours,
+ "12:00", "01:30"));
+ TextView type = rootView.findViewById(R.id.restaurant_type);
+ type.setText(getString(R.string.restaurant_type, "Bar"));
+ TextView averageRatings = rootView.findViewById(R.id.restaurant_average_rating);
+ averageRatings.setText(getString(R.string.restaurant_average_rating, 4.78));
+
+ LinearLayout averageRatingPerDiet = rootView.findViewById(R.id.restaurant_average_rating_per_diet);
+ TextView dietRatingView = new TextView(getContext());
+ dietRatingView.setText(getString(R.string.restaurant_diet_average_rating, "όγκος", 4.65));
+ averageRatingPerDiet.addView(dietRatingView);
+ dietRatingView = new TextView(getContext());
+ dietRatingView.setText(getString(R.string.restaurant_diet_average_rating, "vegan", 2.23));
+ averageRatingPerDiet.addView(dietRatingView);
gMapView = rootView.findViewById(R.id.restaurant_map);
gMapView.getMapAsync(this);
gMapView.onCreate(getArguments());
-
return rootView;
}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java
new file mode 100644
index 0000000..695ebc6
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantItemAdapter.java
@@ -0,0 +1,69 @@
+package gr.auth.databases.flavours.activities.restaurant.fragments;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+
+import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+import androidx.recyclerview.widget.RecyclerView;
+import gr.auth.databases.flavours.R;
+import gr.auth.databases.flavours.base.BaseFragment;
+import gr.auth.databases.flavours.model.ItemSummary;
+
+public class RestaurantItemAdapter extends RecyclerView.Adapter {
+ private final RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener interactionListener;
+ private final ArrayList items;
+
+ RestaurantItemAdapter(BaseFragment.FragmentInteractionListener interactionListener,
+ ArrayList items) {
+ this.interactionListener = (RestaurantFoodsFragment.RestaurantFoodsFragmentInteractionListener) interactionListener;
+ this.items = items;
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext()).
+ inflate(R.layout.restaurant_item_row, parent, false);
+ return new ItemViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) {
+ ItemSummary item = items.get(position);
+ ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
+
+ itemViewHolder.card.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (interactionListener != null) {
+ // Notify the active callbacks interface (the activity, if the
+ // fragment is attached to one) that an item has been selected.
+ interactionListener.onRestaurantFoodsFragmentInteraction(items.get(holder.getAdapterPosition()));
+ }
+ }
+ });
+
+ itemViewHolder.item.setText(item.getItem());
+ }
+
+ @Override
+ public int getItemCount() {
+ return items == null ? 0 : items.size();
+ }
+
+ private static class ItemViewHolder extends RecyclerView.ViewHolder {
+ CardView card;
+ TextView item;
+
+ ItemViewHolder(View itemView) {
+ super(itemView);
+ card = itemView.findViewById(R.id.restaurant_item_row_card);
+ item = itemView.findViewById(R.id.restaurant_item_row_item);
+ }
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java
deleted file mode 100644
index e681ffd..0000000
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantListFragment.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package gr.auth.databases.flavours.activities.restaurant.fragments;
-
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import gr.auth.databases.flavours.R;
-import gr.auth.databases.flavours.activities.restaurant.RestaurantAdapter;
-import gr.auth.databases.flavours.model.Rating;
-
-public class RestaurantListFragment extends Fragment {
- private Rating[] ratings = new Rating[7];
-
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_restaurant_list, container, false);
-
- RecyclerView recyclerView = rootView.findViewById(R.id.restaurant_recycler);
- recyclerView.setHasFixedSize(true);
- LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
- recyclerView.setLayoutManager(layoutManager);
-
- ratings[0] = new Rating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", Rating.Accessibility.MODERATE);
- ratings[1] = new Rating(5, "Ανύπαρκτος", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", Rating.Accessibility.EASY);
- ratings[2] = new Rating(4, "Γαρδένιος ο Stoner", "-", "2018-06-08", Rating.Accessibility.EASY);
- ratings[3] = new Rating(4, "Μαγκούστα", "Μου άρεσε.", "2018-06-08", Rating.Accessibility.MODERATE);
- ratings[4] = new Rating(5, "Νταλίκας", "Τέλειο.", "2018-06-08", Rating.Accessibility.EASY);
- ratings[5] = new Rating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null);
- ratings[6] = new Rating(4, "eddie lives inside you", "-", "2018-06-08", Rating.Accessibility.MODERATE);
-
- RestaurantAdapter restaurantAdapter = new RestaurantAdapter(getContext(), ratings);
- recyclerView.setAdapter(restaurantAdapter);
-
- return rootView;
- }
-}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsAdapter.java
similarity index 66%
rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java
rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsAdapter.java
index 47dacd4..e99e6f9 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/RestaurantAdapter.java
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/activities/restaurant/fragments/RestaurantRatingsAdapter.java
@@ -1,30 +1,31 @@
-package gr.auth.databases.flavours.activities.restaurant;
+package gr.auth.databases.flavours.activities.restaurant.fragments;
import android.content.Context;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import java.util.ArrayList;
+
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import gr.auth.databases.flavours.R;
import gr.auth.databases.flavours.model.Rating;
-public class RestaurantAdapter extends RecyclerView.Adapter {
+public class RestaurantRatingsAdapter extends RecyclerView.Adapter {
private Context context;
- private Rating[] ratings;
+ private ArrayList ratings;
- public RestaurantAdapter(Context context, Rating[] ratings) {
+ RestaurantRatingsAdapter(Context context, ArrayList ratings) {
this.context = context;
this.ratings = ratings;
}
@NonNull
@Override
- public RestaurantAdapter.RatingViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
- int viewType) {
+ public RestaurantRatingsAdapter.RatingViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
+ int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_restaurant_list_row,
parent, false);
return new RatingViewHolder(v);
@@ -32,27 +33,26 @@ public class RestaurantAdapter extends RecyclerView.Adapter ratings = new ArrayList<>();
+ ratings.add(new Rating(5, "Ανώνυμος", "Πάρα πολύ καλό!", "2018-01-04", Rating.Accessibility.MODERATE));
+ ratings.add(new Rating(5, "Ανύπαρκτος", "Εξαιρετικό service.\nΘα ξαναπάω!", "2018-06-08", Rating.Accessibility.EASY));
+ ratings.add(new Rating(4, "Γαρδένιος ο Stoner", "-", "2018-06-08", Rating.Accessibility.EASY));
+ ratings.add(new Rating(4, "Μαγκούστα", "Μου άρεσε.", "2018-06-08", Rating.Accessibility.MODERATE));
+ ratings.add(new Rating(5, "Νταλίκας", "Τέλειο.", "2018-06-08", Rating.Accessibility.EASY));
+ ratings.add(new Rating(2, "Ms Godzila", "Το φαϊ άργησε πάρα πολύ!", "2018-06-08", null));
+ ratings.add(new Rating(4, "eddie lives inside you", "-", "2018-06-08", Rating.Accessibility.MODERATE));
+
+ RestaurantRatingsAdapter itemAdapter = new RestaurantRatingsAdapter(getContext(), ratings);
+ RecyclerView mainContent = rootView.findViewById(R.id.restaurant_list);
+ mainContent.setAdapter(itemAdapter);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
+ mainContent.setLayoutManager(layoutManager);
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mainContent.getContext(),
+ layoutManager.getOrientation());
+ mainContent.addItemDecoration(dividerItemDecoration);
+
+ return rootView;
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java
new file mode 100644
index 0000000..0c627c7
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/base/BaseFragment.java
@@ -0,0 +1,53 @@
+package gr.auth.databases.flavours.base;
+
+import android.content.Context;
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import okhttp3.OkHttpClient;
+
+public abstract class BaseFragment extends Fragment {
+ protected static final String ARG_SECTION_NUMBER = "SectionNumber";
+ protected static final String ARG_TAG = "FragmentTAG";
+
+ protected FragmentInteractionListener fragmentInteractionListener;
+
+ protected static OkHttpClient client;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ //int sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
+ if (client == null)
+ client = BaseApplication.getInstance().getClient(); //must check every time - e.g.
+ // becomes null when app restarts after crash
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ /*if (context instanceof FragmentInteractionListener) {
+ fragmentInteractionListener = (FragmentInteractionListener) context;
+
+ } else {
+ throw new RuntimeException(context.toString()
+ + " must implement OnFragmentInteractionListener");
+ }*/
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ fragmentInteractionListener = null;
+ }
+
+ /**
+ * This interface MUST be extended by the fragment subclass AND implemented by
+ * the activity that contains it, to allow communication upon interaction,
+ * between the fragment and the activity/ other fragments
+ */
+ public interface FragmentInteractionListener {
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java
new file mode 100644
index 0000000..8a24771
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/java/gr/auth/databases/flavours/model/ItemSummary.java
@@ -0,0 +1,23 @@
+package gr.auth.databases.flavours.model;
+
+public class ItemSummary {
+ public enum ItemType {
+ FOOD, DRINK
+ }
+
+ private String item;
+ private ItemType type;
+
+ public ItemSummary(String item, ItemType type) {
+ this.item = item;
+ this.type = type;
+ }
+
+ public String getItem() {
+ return item;
+ }
+
+ public ItemType getType() {
+ return type;
+ }
+}
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml
index 4d0e313..20f812d 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/activity_restaurant.xml
@@ -10,55 +10,26 @@
android:id="@+id/restaurant_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:theme="@style/Theme.AppCompat.Light">
+ android:paddingTop="@dimen/appbar_padding_top"
+ android:theme="@style/ToolbarTheme">
+ android:gravity="center"
+ app:popupTheme="@style/ToolbarTheme"/>
-
-
-
-
-
-
-
-
-
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ app:tabGravity="fill"
+ app:tabMode="fixed"
+ app:tabSelectedTextColor="@color/accent"
+ app:tabTextColor="@color/iron" />
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml
similarity index 51%
rename from UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml
rename to UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml
index 1965e4b..4004e7c 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_list.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_items.xml
@@ -1,10 +1,8 @@
\ No newline at end of file
+ android:orientation="vertical" />
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml
deleted file mode 100644
index 53586fe..0000000
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/fragment_restaurant_map.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/restaurant_item_row.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/restaurant_item_row.xml
new file mode 100644
index 0000000..afbbf92
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/layout/restaurant_item_row.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/dimens.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..85a569e
--- /dev/null
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/dimens.xml
@@ -0,0 +1,4 @@
+
+
+ 8dp
+
\ No newline at end of file
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
index 22aa61c..5366456 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/strings.xml
@@ -44,8 +44,10 @@
Restaurant Name
- Working hours
- Restaurant type
+ Working hours: %1$s - %2$s
+ Restaurant type: %1$s
+ Restaurant average rating: %1$f
+ Restaurant average rating for diet %1$s: %2$f
Grade = %1$d/5
Accessibility = %1$s
diff --git a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/styles.xml b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/styles.xml
index 3f64336..3f628e4 100644
--- a/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/styles.xml
+++ b/UI/AndroidApp/flavoursWithoutBorders/app/src/main/res/values/styles.xml
@@ -7,4 +7,9 @@
- @color/colorAccent
+
\ No newline at end of file