added route singleton

This commit is contained in:
Sem van der Hoeven
2021-01-06 10:48:03 +01:00
parent abc58d3606
commit f6af7ae80b
4 changed files with 46 additions and 18 deletions

View File

@@ -0,0 +1,42 @@
package com.a1.nextlocation.data;
/**
* singleton to track the current route that is being followed
*/
public enum RouteHandler {
INSTANCE;
private boolean isFollowingRoute = false;
private Route currentRoute;
private int stepCount = 0;
public int getStepCount() {
return stepCount;
}
public void addStep() {
stepCount++;
}
public void finishRoute() {
stepCount = 0;
isFollowingRoute = false;
currentRoute = null;
}
public void followRoute(Route route) {
this.currentRoute = route;
setFollowingRoute(true);
}
public boolean isFollowingRoute(Route route) {
return isFollowingRoute && route.equals(currentRoute);
}
public void setFollowingRoute(boolean followingRoute) {
isFollowingRoute = followingRoute;
}
public boolean isFollowingRoute() {
return isFollowingRoute;
}
}