Added route picture, text and total distance in routeDetail

This commit is contained in:
RemoMeijer
2021-01-06 16:54:15 +01:00
parent d67d78b385
commit c921a76dc4
3 changed files with 34 additions and 31 deletions

View File

@@ -1,43 +1,35 @@
[ [
{ {
"name": "rondje stad", "name": "Evenementen Route",
"locations": [ "locations": [
{ {
"name":"Escaping Breda: Escape Room Games Boschstraat 114", "name":"Escaping Breda: Escape Room Games Boschstraat 114",
"coordinates":"51.59096518753322, 4.783727736123234", "coordinates":"51.59096518753322, 4.783727736123234"
"description":"4811GK Breda",
"imageUrl":"NULL"
}, },
{ {
"name":"Prison Escape Kloosterlaan 168", "name":"Prison Escape Kloosterlaan 168",
"coordinates":"51.59058740778487, 4.784723144974098", "coordinates":"51.59058740778487, 4.784723144974098"
"description":"4811EE Breda",
"imageUrl":"NULL"
}, },
{ {
"name":"De Koepel - FutureDome Events Nassausingel 26", "name":"De Koepel - FutureDome Events Nassausingel 26",
"coordinates":"51.59025697138579, 4.787354025225596", "coordinates":"51.59025697138579, 4.787354025225596"
"description":"4811HP Breda",
"imageUrl":"NULL"
}, },
{ {
"name":"MEZZ Breda Keizerstraat 101", "name":"MEZZ Breda Keizerstraat 101",
"coordinates":"51.5837840024532, 4.779037836841554", "coordinates":"51.5837840024532, 4.779037836841554"
"description":"4811HL Breda",
"imageUrl":"NULL"
}, },
{ {
"name":"Het Klooster Breda Schorsmolenstraat 13", "name":"Het Klooster Breda Schorsmolenstraat 13",
"coordinates":"51.58765659148822, 4.764801414019652", "coordinates":"51.58765659148822, 4.764801414019652"
"description":"4811VN Breda",
"imageUrl":"NULL"
} }
], ],
"totalDistance": 1073.0, "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": [ "locations": [
{ {
"name": "McDonald's Breda Karnemelkstraat", "name": "McDonald's Breda Karnemelkstraat",
@@ -71,6 +63,8 @@
} }
], ],
"totalDistance": 955.0, "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"
} }
] ]

View File

@@ -18,6 +18,7 @@ public class Route implements Parcelable {
private String description; private String description;
private List<Location> locations; private List<Location> locations;
private float totalDistance; private float totalDistance;
private String imageURL;
private int totalTime; private int totalTime;
public Route(@NotNull String name) { public Route(@NotNull String name) {
@@ -69,6 +70,10 @@ public class Route implements Parcelable {
return totalDistance; return totalDistance;
} }
public String getImageURL(){
return this.imageURL;
}
public int getTotalTime() { public int getTotalTime() {
//TODO calculate total time according to all locations in list //TODO calculate total time according to all locations in list

View File

@@ -1,6 +1,7 @@
package com.a1.nextlocation.fragments; package com.a1.nextlocation.fragments;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@@ -11,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@@ -26,10 +28,7 @@ import java.util.List;
public class RouteDetailFragment extends Fragment { public class RouteDetailFragment extends Fragment {
private Route route; private Route route;
private TextView routeDetailText; private ImageView imageView;
private TextView routeName;
private TextView totalDistance;
private ImageButton imageButton;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@@ -45,18 +44,23 @@ public class RouteDetailFragment extends Fragment {
this.route = getArguments().getParcelable("route"); this.route = getArguments().getParcelable("route");
} }
this.routeName = view.findViewById(R.id.route_title); this.imageView = view.findViewById(R.id.route_detail_image);
this.routeName.setText(this.route.getName()); 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); TextView routeName = view.findViewById(R.id.route_title);
this.routeDetailText.setText(this.route.getDescription()); 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); 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); ImageButton imageButton = view.findViewById(R.id.route_detail_back_button);
this.imageButton.setOnClickListener(v -> { imageButton.setOnClickListener(v -> {
RouteFragment routeFragment = new RouteFragment(); RouteFragment routeFragment = new RouteFragment();
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit(); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, routeFragment).addToBackStack(null).commit();
}); });