This commit is contained in:
Sem van der Hoeven
2021-01-06 13:54:30 +01:00
parent 1760f510c6
commit bd623a3f1d
4 changed files with 15 additions and 7 deletions

View File

@@ -90,7 +90,7 @@ public class HomeFragment extends Fragment implements LocationListener {
stopButton.setOnClickListener(v -> {
RouteHandler.INSTANCE.finishRoute();
stopButton.setVisibility(View.GONE);
Toast.makeText(requireContext(),getResources().getString(R.string.route_stop_toast),Toast.LENGTH_SHORT).show();
Toast.makeText(requireContext(), getResources().getString(R.string.route_stop_toast), Toast.LENGTH_SHORT).show();
mapView.getOverlays().remove(roadOverlay);
mapView.getOverlays().remove(allLocationsOverlay);
addLocations();
@@ -109,6 +109,7 @@ public class HomeFragment extends Fragment implements LocationListener {
/**
* callback method that gets called when there are new directions available in the form of a {@link DirectionsResult} object.
*
* @param directionsResult the directions received from the api
*/
private void onDirectionsAvailable(DirectionsResult directionsResult) {
@@ -285,9 +286,9 @@ public class HomeFragment extends Fragment implements LocationListener {
}
/**
* @param permissions tbe permissions we want to ask
* @author Ricky
* request the permissions needed for location and network, made by Ricky
* @param permissions tbe permissions we want to ask
*/
private void requestPermissionsIfNecessary(String... permissions) {
ArrayList<String> permissionsToRequest = new ArrayList<>();
@@ -309,14 +310,17 @@ public class HomeFragment extends Fragment implements LocationListener {
/**
* location callback that gets called each time the location is updated. It is used for updating the distance walked and checking if there are locations you have visited
*
* @param location the new location
*/
@Override
public void onLocationChanged(@NonNull Location location) {
// calculate the distance walked
if (currentLocation != null && currentLocation.getLatitude() != 0 && currentLocation.getLongitude() != 0) {
double distance = currentLocation.distanceTo(location); // in meters
StaticData.INSTANCE.addDistance(distance);
currentLocation = location;
}
//new thread because we don't want the main thread to hang, this method gets called a lot
Thread t = new Thread(() -> {

View File

@@ -36,7 +36,7 @@ public class RouteDetailFragment extends Fragment {
this.route = getArguments().getParcelable("route");
}
this.routeDetailText = view.findViewById(R.id.routeDetailText);
this.routeDetailText = view.findViewById(R.id.reoute_detail_tekst);
this.routeDetailText.setText(this.route.getName());
Button startButton = view.findViewById(R.id.start_route_button);
startButton.setOnClickListener(this::startRoute);

View File

@@ -132,6 +132,10 @@ public class DirectionsResult {
}
/**
* parses the given json string into this object. This method is used for when you want to
* @param json
*/
public void parseRoute(String json) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();

View File

@@ -24,7 +24,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@string/naam"
android:text="@string/app_name"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"