diff options
Diffstat (limited to 'main/src/cgeo/geocaching/cgCache.java')
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 37286f1..8bf8871 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -97,6 +97,7 @@ public class cgCache implements ICache { private String directionImg = ""; private String nameForSorting; private final EnumSet<StorageLocation> storageLocation = EnumSet.of(StorageLocation.HEAP); + private boolean finalDefined = false; private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+"); @@ -123,6 +124,7 @@ public class cgCache implements ICache { favorite = other.favorite; onWatchlist = other.onWatchlist; logOffline = other.logOffline; + finalDefined = other.finalDefined; } /* @@ -312,7 +314,8 @@ public class cgCache implements ICache { logs == other.logs && inventory == other.inventory && logCounts == other.logCounts && - logOffline == other.logOffline) { + logOffline == other.logOffline && + finalDefined == other.finalDefined) { return true; } return false; @@ -889,9 +892,13 @@ public class cgCache implements ICache { public void setWaypoints(List<cgWaypoint> waypoints) { this.waypoints = waypoints; + finalDefined = false; if (waypoints != null) { for (cgWaypoint waypoint : waypoints) { waypoint.setGeocode(geocode); + if (isFinalWithCoords(waypoint)) { + finalDefined = true; + } } } } @@ -1094,12 +1101,41 @@ public class cgCache implements ICache { } waypoints.add(waypoint); waypoint.setGeocode(geocode); + if (isFinalWithCoords(waypoint)) { + finalDefined = true; + } } public boolean hasWaypoints() { return CollectionUtils.isNotEmpty(waypoints); } + public boolean hasFinalDefined() { + return finalDefined; + } + + // Only for loading + public void setFinalDefined(boolean finalDefined) { + this.finalDefined = finalDefined; + } + + /** + * Checks whether a given waypoint is a final and has coordinates + * + * @param waypoint + * Waypoint to check + * @return True - waypoint is final and has coordinates, False - otherwise + */ + private static boolean isFinalWithCoords(cgWaypoint waypoint) { + if (null != waypoint.getWaypointType() && WaypointType.FINAL == waypoint.getWaypointType()) { + if (null != waypoint.getCoords()) { + return true; + } + } + + return false; + } + public boolean hasUserModifiedCoords() { return userModifiedCoords; } @@ -1148,6 +1184,15 @@ public class cgCache implements ICache { waypoints.remove(index); cgeoapplication.getInstance().deleteWaypoint(waypoint.getId()); cgeoapplication.getInstance().removeCache(geocode, EnumSet.of(RemoveFlag.REMOVECACHE)); + // Check status if Final is defined + if (isFinalWithCoords(waypoint)) { + finalDefined = false; + for (cgWaypoint wp : waypoints) { + if (isFinalWithCoords(wp)) { + finalDefined = true; + } + } + } return true; } return false; @@ -1192,7 +1237,7 @@ public class cgCache implements ICache { // coords must have non zero latitude and longitude and at least one part shall have fractional degrees if (point != null && point.getLatitudeE6() != 0 && point.getLongitudeE6() != 0 && ((point.getLatitudeE6() % 1000) != 0 || (point.getLongitudeE6() % 1000) != 0)) { final String name = cgeoapplication.getInstance().getString(R.string.cache_personal_note) + " " + count; - final cgWaypoint waypoint = new cgWaypoint(name, WaypointType.WAYPOINT); + final cgWaypoint waypoint = new cgWaypoint(name, WaypointType.WAYPOINT, false); waypoint.setCoords(point); addWaypoint(waypoint); count++; |
