added visited locations in route

This commit is contained in:
Sem van der Hoeven
2021-01-14 10:48:52 +01:00
parent 018de5688e
commit f7691d62fe
3 changed files with 18 additions and 1 deletions

View File

@@ -112,4 +112,13 @@ public class Route implements Parcelable {
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public void setLocationVisited(Location location) {
for (Location l : this.locations) {
if (l.getName().equals(location.getName())) {
l.setVisited(true);
break;
}
}
}
} }

View File

@@ -64,6 +64,14 @@ public enum RouteHandler {
Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime); Data.INSTANCE.addTimeWalked(System.currentTimeMillis() - startedTime);
} }
this.currentRoute = route; this.currentRoute = route;
// sync the visited locations with the route
for (Location l : this.currentRoute.getLocations()) {
if (Data.INSTANCE.isVisited(l)) {
this.currentRoute.setLocationVisited(l);
}
}
setFollowingRoute(true); setFollowingRoute(true);
startedTime = System.currentTimeMillis(); startedTime = System.currentTimeMillis();
} }

View File

@@ -263,7 +263,7 @@ public class HomeFragment extends Fragment implements LocationListener {
for (com.a1.nextlocation.data.Location location : locations) { for (com.a1.nextlocation.data.Location location : locations) {
OverlayItem item = new OverlayItem(location.getName(), location.getDescription(), location.convertToGeoPoint()); OverlayItem item = new OverlayItem(location.getName(), location.getDescription(), location.convertToGeoPoint());
Drawable marker = null; Drawable marker = null;
if (location.isVisited() && Data.INSTANCE.isVisited(location)) { if (location.isVisited()) {
Log.d(TAG, "addLocations: location " + location.getName() + " is visited"); Log.d(TAG, "addLocations: location " + location.getName() + " is visited");
marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24); marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24);
marker.setAlpha(255); marker.setAlpha(255);