color change

This commit is contained in:
Sem van der Hoeven
2021-01-12 16:40:24 +01:00
parent 036278f829
commit 43c3060f1e
2 changed files with 12 additions and 4 deletions

View File

@@ -113,6 +113,10 @@ public enum Data {
this.totalTime = prefs.getLong("timeWalked", 0); this.totalTime = prefs.getLong("timeWalked", 0);
} }
public boolean isVisited(Location location) {
return this.visitedNames.contains(location.getName());
}
public android.location.Location getLocation() { public android.location.Location getLocation() {
return location; return location;
} }

View File

@@ -261,13 +261,17 @@ public class HomeFragment extends Fragment implements LocationListener {
initializer.removeGeoFences(); initializer.removeGeoFences();
final ArrayList<OverlayItem> items = new ArrayList<>(locations.size()); final ArrayList<OverlayItem> items = new ArrayList<>(locations.size());
// marker icon // marker icon
Drawable marker = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24);
marker.setAlpha(255);
marker.setTint(getResources().getColor(R.color.secondaryColour));
// add all locations to the overlay itemss // add all locations to the overlay itemss
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 = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_location_on_24);
marker.setAlpha(255);
if (location.isVisited() && Data.INSTANCE.isVisited(location)) {
marker.setTint(getResources().getColor(R.color.red));
} else {
marker.setTint(getResources().getColor(R.color.secondaryColour));
}
item.setMarker(marker); item.setMarker(marker);
items.add(item); items.add(item);
} }
@@ -313,6 +317,7 @@ public class HomeFragment extends Fragment implements LocationListener {
mapView.getOverlays().add(allLocationsOverlay); mapView.getOverlays().add(allLocationsOverlay);
Log.d(TAG, "addLocations: successfully added locations"); Log.d(TAG, "addLocations: successfully added locations");
mapView.invalidate();
addGeofences(locations); addGeofences(locations);
} }
@@ -397,7 +402,6 @@ public class HomeFragment extends Fragment implements LocationListener {
public void onLocationVisited(com.a1.nextlocation.data.Location location) { public void onLocationVisited(com.a1.nextlocation.data.Location location) {
Data.INSTANCE.visitLocation(location); Data.INSTANCE.visitLocation(location);
showNotification(location); showNotification(location);
} }
private void showNotification(com.a1.nextlocation.data.Location location) { private void showNotification(com.a1.nextlocation.data.Location location) {