Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop route werkend #58

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/java/nl/ags/picum/UI/MapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public List<GeoPoint> convertWayPointToGeoPoint(List<Waypoint> points) {

public void onFSBClicked(View view) {
if (this.mapViewModel == null) return;
mapViewModel.getMapManager().stopRoute(mapViewModel.getCurrentRoute());
new Thread(() ->{ mapViewModel.getMapManager().stopRoute(mapViewModel.getCurrentRoute());}).start();
finish();
}
}
7 changes: 7 additions & 0 deletions app/src/main/java/nl/ags/picum/location/gps/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public void onReceive(Context context, Intent intent) {
};
}

public void stop() {

fusedLocationClient.removeLocationUpdates(getLocationCallback());
this.isRunning = false;

}

@SuppressLint("MissingPermission")
//you must listen to LocationObserver.onLocationUpdate() for the returnvalue of this method
private void getLastLocation() {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/nl/ags/picum/mapManagement/MapManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ public void startGPSUpdates() {
locationService.start(this);
}

public void stopGPSUpdates(){
locationService.stop();
}

@Override
public void onLocationError() {
// On Error, log the error
Expand Down Expand Up @@ -323,6 +327,7 @@ private void sortPointByVisited(Point currentLocation) {
public void stopRoute(Route route){
DataStorage dataStorage = AppDatabaseManager.getInstance(context);
dataStorage.stopRoute(route);
stopGPSUpdates();
}

private void markRouteOfSight(Waypoint waypoint) {
Expand Down