diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2012-02-27 22:02:22 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2012-02-27 22:02:22 +0100 |
| commit | 56c1ffd7689fdc5eb062c592880c5dabdfa2276a (patch) | |
| tree | f75dcba62d4872f2961c25a4a86e3eab66d0149d /main/src | |
| parent | a4ac7464db219517ab6db45dad860f9c3abc5979 (diff) | |
| download | cgeo-56c1ffd7689fdc5eb062c592880c5dabdfa2276a.zip cgeo-56c1ffd7689fdc5eb062c592880c5dabdfa2276a.tar.gz cgeo-56c1ffd7689fdc5eb062c592880c5dabdfa2276a.tar.bz2 | |
refactoring: move isFinalDefined to WayPoint class
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 29 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgWaypoint.java | 8 |
2 files changed, 15 insertions, 22 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index f49dffe..e308209 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -113,8 +113,9 @@ public class cgCache implements ICache { * Sends a change notification to interested parties */ private void notifyChange() { - if (changeNotificationHandler != null) + if (changeNotificationHandler != null) { changeNotificationHandler.sendEmptyMessage(0); + } } /** @@ -920,7 +921,7 @@ public class cgCache implements ICache { if (waypoints != null) { for (cgWaypoint waypoint : waypoints) { waypoint.setGeocode(geocode); - if (isFinalWithCoords(waypoint)) { + if (waypoint.isFinalWithCoords()) { finalDefined = true; } } @@ -1125,7 +1126,7 @@ public class cgCache implements ICache { } waypoints.add(waypoint); waypoint.setGeocode(geocode); - if (isFinalWithCoords(waypoint)) { + if (waypoint.isFinalWithCoords()) { finalDefined = true; } } @@ -1143,23 +1144,6 @@ public class cgCache implements ICache { 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; } @@ -1209,11 +1193,12 @@ public class cgCache implements ICache { cgeoapplication.getInstance().deleteWaypoint(waypoint.getId()); cgeoapplication.getInstance().removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); // Check status if Final is defined - if (isFinalWithCoords(waypoint)) { + if (waypoint.isFinalWithCoords()) { finalDefined = false; for (cgWaypoint wp : waypoints) { - if (isFinalWithCoords(wp)) { + if (wp.isFinalWithCoords()) { finalDefined = true; + break; } } } diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java index 5c926db..7287d2d 100644 --- a/main/src/cgeo/geocaching/cgWaypoint.java +++ b/main/src/cgeo/geocaching/cgWaypoint.java @@ -236,4 +236,12 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> { return name + " " + waypointType.getL10n(); } + /** + * Checks whether a given waypoint is a final and has coordinates + * + * @return True - waypoint is final and has coordinates, False - otherwise + */ + public boolean isFinalWithCoords() { + return WaypointType.FINAL == getWaypointType() && null != getCoords(); + } }
\ No newline at end of file |
