diff --git a/app/src/main/assets/routes.json b/app/src/main/assets/routes.json index 641cdc9..8520041 100644 --- a/app/src/main/assets/routes.json +++ b/app/src/main/assets/routes.json @@ -1,43 +1,35 @@ [ { - "name": "rondje stad", + "name": "Evenementen Route", "locations": [ { "name":"Escaping Breda: Escape Room Games Boschstraat 114", - "coordinates":"51.59096518753322, 4.783727736123234", - "description":"4811GK Breda", - "imageUrl":"NULL" + "coordinates":"51.59096518753322, 4.783727736123234" }, { "name":"Prison Escape Kloosterlaan 168", - "coordinates":"51.59058740778487, 4.784723144974098", - "description":"4811EE Breda", - "imageUrl":"NULL" + "coordinates":"51.59058740778487, 4.784723144974098" }, { "name":"De Koepel - FutureDome Events Nassausingel 26", - "coordinates":"51.59025697138579, 4.787354025225596", - "description":"4811HP Breda", - "imageUrl":"NULL" + "coordinates":"51.59025697138579, 4.787354025225596" }, { "name":"MEZZ Breda Keizerstraat 101", - "coordinates":"51.5837840024532, 4.779037836841554", - "description":"4811HL Breda", - "imageUrl":"NULL" + "coordinates":"51.5837840024532, 4.779037836841554" }, { "name":"Het Klooster Breda Schorsmolenstraat 13", - "coordinates":"51.58765659148822, 4.764801414019652", - "description":"4811VN Breda", - "imageUrl":"NULL" + "coordinates":"51.58765659148822, 4.764801414019652" } ], "totalDistance": 1073.0, - "totalTime": 342342 + "totalTime": 342342, + "description": "Deze route laat u leuke events verspreid door breda zien! Probeer de escaperooms uit, een event bij de koepel, of een leuk feest bij MEZZ! Met deze route loopt u langs ze allemaal.", + "imageURL": "escaping_room" }, { - "name": "Obesi Route", + "name": "Hongerige Route", "locations": [ { "name": "McDonald's Breda Karnemelkstraat", @@ -71,6 +63,8 @@ } ], "totalDistance": 955.0, - "totalTime": 342342 + "totalTime": 342342, + "description": "Met deze route bezoekt u alle snackbars en restaurants in het centrum van Breda!", + "imageURL": "kees_kroket" } ] \ No newline at end of file diff --git a/app/src/main/java/com/a1/nextlocation/data/Route.java b/app/src/main/java/com/a1/nextlocation/data/Route.java index 3138556..dd48247 100644 --- a/app/src/main/java/com/a1/nextlocation/data/Route.java +++ b/app/src/main/java/com/a1/nextlocation/data/Route.java @@ -18,6 +18,7 @@ public class Route implements Parcelable { private String description; private List locations; private float totalDistance; + private String imageURL; private int totalTime; public Route(@NotNull String name) { @@ -69,6 +70,10 @@ public class Route implements Parcelable { return totalDistance; } + public String getImageURL(){ + return this.imageURL; + } + public int getTotalTime() { //TODO calculate total time according to all locations in list diff --git a/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java index f0a7f5a..1c258e9 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/RouteDetailFragment.java @@ -1,6 +1,7 @@ package com.a1.nextlocation.fragments; import android.annotation.SuppressLint; +import android.content.Context; import android.os.Bundle; import androidx.fragment.app.Fragment; @@ -11,6 +12,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.Button; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -26,10 +28,7 @@ import java.util.List; public class RouteDetailFragment extends Fragment { private Route route; - private TextView routeDetailText; - private TextView routeName; - private TextView totalDistance; - private ImageButton imageButton; + private ImageView imageView; @Override public void onCreate(Bundle savedInstanceState) { @@ -45,18 +44,23 @@ public class RouteDetailFragment extends Fragment { this.route = getArguments().getParcelable("route"); } - this.routeName = view.findViewById(R.id.route_title); - this.routeName.setText(this.route.getName()); + this.imageView = view.findViewById(R.id.route_detail_image); + Context context = this.imageView.getContext(); + int id = context.getResources().getIdentifier(this.route.getImageURL(), "drawable", context.getPackageName()); + this.imageView.setImageResource(id); - this.routeDetailText = view.findViewById(R.id.reoute_detail_tekst); - this.routeDetailText.setText(this.route.getDescription()); + TextView routeName = view.findViewById(R.id.route_title); + routeName.setText(this.route.getName()); - this.totalDistance = view.findViewById(R.id.total_distance); + TextView routeDetailText = view.findViewById(R.id.reoute_detail_tekst); + routeDetailText.setText(this.route.getDescription()); + + TextView totalDistance = view.findViewById(R.id.total_distance); String distance_tekst = getResources().getString(R.string.total_distance_route); - this.totalDistance.setText(distance_tekst + " " + calculateRoute(this.route.getLocations()) + "m"); + totalDistance.setText(distance_tekst + " " + calculateRoute(this.route.getLocations()) + "m"); - this.imageButton = view.findViewById(R.id.route_detail_back_button); - this.imageButton.setOnClickListener(v -> { + ImageButton imageButton = view.findViewById(R.id.route_detail_back_button); + imageButton.setOnClickListener(v -> { RouteFragment routeFragment = new RouteFragment(); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit(); });