stuff
This commit is contained in:
@@ -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.
|
* 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
|
* @param directionsResult the directions received from the api
|
||||||
*/
|
*/
|
||||||
private void onDirectionsAvailable(DirectionsResult directionsResult) {
|
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
|
* @author Ricky
|
||||||
* request the permissions needed for location and network, made by 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) {
|
private void requestPermissionsIfNecessary(String... permissions) {
|
||||||
ArrayList<String> permissionsToRequest = new ArrayList<>();
|
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
|
* 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
|
* @param location the new location
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(@NonNull Location location) {
|
public void onLocationChanged(@NonNull Location location) {
|
||||||
// calculate the distance walked
|
// calculate the distance walked
|
||||||
|
if (currentLocation != null && currentLocation.getLatitude() != 0 && currentLocation.getLongitude() != 0) {
|
||||||
double distance = currentLocation.distanceTo(location); // in meters
|
double distance = currentLocation.distanceTo(location); // in meters
|
||||||
StaticData.INSTANCE.addDistance(distance);
|
StaticData.INSTANCE.addDistance(distance);
|
||||||
currentLocation = location;
|
currentLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
//new thread because we don't want the main thread to hang, this method gets called a lot
|
//new thread because we don't want the main thread to hang, this method gets called a lot
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class RouteDetailFragment extends Fragment {
|
|||||||
this.route = getArguments().getParcelable("route");
|
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());
|
this.routeDetailText.setText(this.route.getName());
|
||||||
Button startButton = view.findViewById(R.id.start_route_button);
|
Button startButton = view.findViewById(R.id.start_route_button);
|
||||||
startButton.setOnClickListener(this::startRoute);
|
startButton.setOnClickListener(this::startRoute);
|
||||||
|
|||||||
@@ -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) {
|
public void parseRoute(String json) {
|
||||||
|
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:text="@string/naam"
|
android:text="@string/app_name"
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
Reference in New Issue
Block a user