From 3fb0e5f2d74b851836473a780a593cc7893cca9a Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Mon, 7 Jan 2013 21:50:10 +0100 Subject: Refactoring: rename cgWaypoint into Waypoint --- main/src/cgeo/geocaching/CacheDetailActivity.java | 26 +-- main/src/cgeo/geocaching/EditWaypointActivity.java | 6 +- main/src/cgeo/geocaching/StaticMapsActivity.java | 4 +- main/src/cgeo/geocaching/StaticMapsProvider.java | 10 +- main/src/cgeo/geocaching/Waypoint.java | 245 +++++++++++++++++++++ main/src/cgeo/geocaching/WaypointPopup.java | 2 +- .../src/cgeo/geocaching/apps/AbstractLocusApp.java | 10 +- .../cache/navi/AbstractPointNavigationApp.java | 6 +- .../apps/cache/navi/AbstractStaticMapsApp.java | 6 +- .../geocaching/apps/cache/navi/CompassApp.java | 6 +- .../apps/cache/navi/DownloadStaticMapsApp.java | 6 +- .../geocaching/apps/cache/navi/InternalMap.java | 6 +- .../cgeo/geocaching/apps/cache/navi/LocusApp.java | 6 +- .../apps/cache/navi/NavigationAppFactory.java | 20 +- .../cgeo/geocaching/apps/cache/navi/RMapsApp.java | 6 +- .../geocaching/apps/cache/navi/StaticMapApp.java | 6 +- .../apps/cache/navi/WaypointNavigationApp.java | 6 +- main/src/cgeo/geocaching/cgCache.java | 40 ++-- main/src/cgeo/geocaching/cgData.java | 26 +-- main/src/cgeo/geocaching/cgWaypoint.java | 245 --------------------- .../src/cgeo/geocaching/connector/gc/GCParser.java | 8 +- main/src/cgeo/geocaching/export/GpxExport.java | 16 +- main/src/cgeo/geocaching/files/GPXParser.java | 10 +- main/src/cgeo/geocaching/maps/CGeoMap.java | 14 +- main/src/cgeo/geocaching/ui/Formatter.java | 6 +- 25 files changed, 371 insertions(+), 371 deletions(-) create mode 100644 main/src/cgeo/geocaching/Waypoint.java delete mode 100644 main/src/cgeo/geocaching/cgWaypoint.java (limited to 'main') diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 03759d0..e63f48d 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -375,9 +375,9 @@ public class CacheDetailActivity extends AbstractViewPagerActivity sortedWaypoints = new ArrayList(cache.getWaypoints()); + final List sortedWaypoints = new ArrayList(cache.getWaypoints()); Collections.sort(sortedWaypoints); - final cgWaypoint waypoint = sortedWaypoints.get(i); + final Waypoint waypoint = sortedWaypoints.get(i); final int index = cache.getWaypoints().indexOf(waypoint); menu.setHeaderTitle(res.getString(R.string.waypoint)); if (waypoint.getWaypointType().equals(WaypointType.ORIGINAL)) { @@ -460,40 +460,40 @@ public class CacheDetailActivity extends AbstractViewPagerActivity sortedWaypoints = new ArrayList(cache.getWaypoints()); + final List sortedWaypoints = new ArrayList(cache.getWaypoints()); Collections.sort(sortedWaypoints); - for (final cgWaypoint wpt : sortedWaypoints) { + for (final Waypoint wpt : sortedWaypoints) { final LinearLayout waypointView = (LinearLayout) getLayoutInflater().inflate(R.layout.waypoint_item, null); // coordinates @@ -2250,7 +2250,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity { + + public static final String PREFIX_OWN = "OWN"; + private static final int ORDER_UNDEFINED = -2; + private int id = 0; + private String geocode = "geocode"; + private WaypointType waypointType = WaypointType.WAYPOINT; + private String prefix = ""; + private String lookup = ""; + private String name = ""; + private String latlon = ""; + private Geopoint coords = null; + private String note = ""; + private int cachedOrder = ORDER_UNDEFINED; + private boolean own = false; + + /** + * require name and type for every waypoint + * + * @param name + * @param type + */ + public Waypoint(final String name, final WaypointType type, final boolean own) { + this.name = name; + this.waypointType = type; + this.own = own; + } + + /** + * copy constructor + * + * @param other + */ + public Waypoint(final Waypoint other) { + merge(other); + this.waypointType = other.waypointType; + id = 0; + } + + public void setIcon(final Resources res, final TextView nameView) { + nameView.setCompoundDrawablesWithIntrinsicBounds(res.getDrawable(waypointType.markerId), null, null, null); + } + + public void merge(final Waypoint old) { + if (StringUtils.isBlank(prefix)) { + setPrefix(old.prefix); + } + if (StringUtils.isBlank(lookup)) { + lookup = old.lookup; + } + if (StringUtils.isBlank(name)) { + setName(old.name); + } + if (StringUtils.isBlank(latlon) || latlon.startsWith("?")) { // there are waypoints containing "???" + latlon = old.latlon; + } + if (coords == null) { + coords = old.coords; + } + if (StringUtils.isBlank(note)) { + note = old.note; + } + if (note != null && old.note != null) { + if (old.note.length() > note.length()) { + note = old.note; + } + } + } + + public static void mergeWayPoints(List newPoints, + List oldPoints, boolean forceMerge) { + // copy user modified details of the waypoints + if (newPoints != null && oldPoints != null) { + for (Waypoint old : oldPoints) { + if (old != null) { + boolean merged = false; + if (StringUtils.isNotEmpty(old.name)) { + for (Waypoint waypoint : newPoints) { + if (waypoint != null && waypoint.name != null) { + if (old.name.equalsIgnoreCase(waypoint.name)) { + waypoint.merge(old); + merged = true; + break; + } + } + } + } + // user added waypoints should also be in the new list + if (!merged && (old.isUserDefined() || forceMerge)) { + newPoints.add(old); + } + } + } + } + } + + public boolean isUserDefined() { + return own || WaypointType.OWN == waypointType; + } + + public void setUserDefined() { + own = true; + setPrefix(PREFIX_OWN); + } + + private int computeOrder() { + switch (waypointType) { + case PARKING: + return -1; + case TRAILHEAD: + return 1; + case STAGE: // puzzles and stages with same value + return 2; + case PUZZLE: + return 2; + case FINAL: + return 3; + case OWN: + return 4; + default: + return 0; + } + } + + private int order() { + if (cachedOrder == ORDER_UNDEFINED) { + cachedOrder = computeOrder(); + } + return cachedOrder; + } + + @Override + public int compareTo(Waypoint other) { + return order() - other.order(); + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + cachedOrder = ORDER_UNDEFINED; + } + + public String getUrl() { + return "http://www.geocaching.com//seek/cache_details.aspx?wp=" + geocode; + } + + @Override + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + public String getGeocode() { + return geocode; + } + + public void setGeocode(String geocode) { + this.geocode = StringUtils.upperCase(geocode); + } + + @Override + public WaypointType getWaypointType() { + return waypointType; + } + + public String getLookup() { + return lookup; + } + + public void setLookup(String lookup) { + this.lookup = lookup; + } + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLatlon() { + return latlon; + } + + public void setLatlon(String latlon) { + this.latlon = latlon; + } + + @Override + public Geopoint getCoords() { + return coords; + } + + public void setCoords(Geopoint coords) { + this.coords = coords; + } + + public String getNote() { + return note; + } + + public void setNote(String note) { + this.note = note; + } + + @Override + public String toString() { + 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 == waypointType && null != coords; + } + + @Override + public String getCoordType() { + return "waypoint"; + } +} diff --git a/main/src/cgeo/geocaching/WaypointPopup.java b/main/src/cgeo/geocaching/WaypointPopup.java index eb0bc17..cc99abd 100644 --- a/main/src/cgeo/geocaching/WaypointPopup.java +++ b/main/src/cgeo/geocaching/WaypointPopup.java @@ -19,7 +19,7 @@ import android.widget.TextView; public class WaypointPopup extends AbstractPopupActivity { private static final String EXTRA_WAYPOINT_ID = "waypoint_id"; private int waypointId = 0; - private cgWaypoint waypoint = null; + private Waypoint waypoint = null; public WaypointPopup() { super("c:geo-waypoint-info", R.layout.waypoint_popup); diff --git a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java index 8f61e72..ad421f6 100644 --- a/main/src/cgeo/geocaching/apps/AbstractLocusApp.java +++ b/main/src/cgeo/geocaching/apps/AbstractLocusApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; @@ -68,8 +68,8 @@ public abstract class AbstractLocusApp extends AbstractApp { // get icon and Point if (o instanceof cgCache) { p = getCachePoint((cgCache) o, withCacheWaypoints, withCacheDetails); - } else if (o instanceof cgWaypoint) { - p = getWaypointPoint((cgWaypoint) o); + } else if (o instanceof Waypoint) { + p = getWaypointPoint((Waypoint) o); } if (p != null) { pd.addPoint(p); @@ -146,7 +146,7 @@ public abstract class AbstractLocusApp extends AbstractApp { if (withWaypoints && cache.hasWaypoints()) { pg.waypoints = new ArrayList(); - for (cgWaypoint waypoint : cache.getWaypoints()) { + for (Waypoint waypoint : cache.getWaypoints()) { if (waypoint == null || waypoint.getCoords() == null) { continue; } @@ -182,7 +182,7 @@ public abstract class AbstractLocusApp extends AbstractApp { * @param waypoint * @return null, when the Point could not be constructed */ - private static Point getWaypointPoint(cgWaypoint waypoint) { + private static Point getWaypointPoint(Waypoint waypoint) { if (waypoint == null || waypoint.getCoords() == null) { return null; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java index ca8c7db..67aa849 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.apps.AbstractApp; import android.app.Activity; @@ -25,7 +25,7 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { navigate(activity, waypoint.getCoords()); } @@ -35,7 +35,7 @@ abstract class AbstractPointNavigationApp extends AbstractApp implements CacheNa } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return waypoint.getCoords() != null; } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java index 85a4b93..e6bf9f4 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractStaticMapsApp.java @@ -4,9 +4,9 @@ import cgeo.geocaching.ILogable; import cgeo.geocaching.R; import cgeo.geocaching.StaticMapsActivity; import cgeo.geocaching.StaticMapsProvider; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgData; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.apps.AbstractApp; @@ -29,7 +29,7 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat return false; } - protected static boolean hasStaticMap(cgWaypoint waypoint) { + protected static boolean hasStaticMap(Waypoint waypoint) { if (waypoint==null) { return false; } @@ -41,7 +41,7 @@ abstract class AbstractStaticMapsApp extends AbstractApp implements CacheNavigat return false; } - protected static boolean invokeStaticMaps(final Activity activity, final cgCache cache, final cgWaypoint waypoint, final boolean download) { + protected static boolean invokeStaticMaps(final Activity activity, final cgCache cache, final Waypoint waypoint, final boolean download) { final ILogable logable = cache != null && cache.getListId() != 0 ? cache : waypoint; // If the cache is not stored for offline, cache seems to be null and waypoint may be null too if (logable==null || logable.getGeocode()==null ) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java index 5275d53..330c338 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeonavigate; import cgeo.geocaching.apps.AbstractApp; import cgeo.geocaching.geopoint.Geopoint; @@ -27,13 +27,13 @@ class CompassApp extends AbstractApp implements CacheNavigationApp, WaypointNavi } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { cgeonavigate.startActivity(activity, waypoint.getPrefix() + "/" + waypoint.getLookup(), waypoint.getName(), waypoint.getCoords(), null, waypoint.getWaypointType().getL10n()); } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return waypoint.getCoords() != null; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java index faf3c36..846b9bc 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/DownloadStaticMapsApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import android.app.Activity; @@ -18,7 +18,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp { } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return !hasStaticMap(waypoint); } @@ -28,7 +28,7 @@ class DownloadStaticMapsApp extends AbstractStaticMapsApp { } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { invokeStaticMaps(activity, null, waypoint, true); } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java index 8185f40..db842ad 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.apps.AbstractApp; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; @@ -27,12 +27,12 @@ class InternalMap extends AbstractApp implements CacheNavigationApp, WaypointNav } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { CGeoMap.startActivityCoords(activity, waypoint.getCoords(), waypoint.getWaypointType(), waypoint.getName()); } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return waypoint.getCoords() != null; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java index a20f2ce..b326105 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.apps.AbstractLocusApp; import android.app.Activity; @@ -11,7 +11,7 @@ import java.util.Collections; class LocusApp extends AbstractLocusApp implements CacheNavigationApp, WaypointNavigationApp { @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return waypoint.getCoords() != null; } @@ -21,7 +21,7 @@ class LocusApp extends AbstractLocusApp implements CacheNavigationApp, WaypointN * */ @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { showInLocus(Collections.singletonList(waypoint), true, false, activity); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index 2f8ce16..8effc05 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -2,8 +2,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.Settings; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.apps.AbstractAppFactory; @@ -96,7 +96,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * Default way to handle selection of navigation tool.
* A dialog is created for tool selection and the selected tool is started afterwards. *

- * Delegates to {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} with + * Delegates to {@link #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint, boolean, boolean)} with * showInternalMap = true and showDefaultNavigation = false * * @param activity @@ -105,7 +105,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param destination */ public static void showNavigationMenu(final Activity activity, - final cgCache cache, final cgWaypoint waypoint, final Geopoint destination) { + final cgCache cache, final Waypoint waypoint, final Geopoint destination) { showNavigationMenu(activity, cache, waypoint, destination, true, false); } @@ -125,10 +125,10 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param showDefaultNavigation * should be false by default * - * @see #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint) + * @see #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint) */ public static void showNavigationMenu(final Activity activity, - final cgCache cache, final cgWaypoint waypoint, final Geopoint destination, + final cgCache cache, final Waypoint waypoint, final Geopoint destination, final boolean showInternalMap, final boolean showDefaultNavigation) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(R.string.cache_menu_navigate); @@ -219,7 +219,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * Use {@link #onMenuItemSelected(MenuItem, Activity, cgCache)} on * selection event to start the selected navigation tool. * - * Only use this way if {@link #showNavigationMenu(Activity, cgCache, cgWaypoint, Geopoint, boolean, boolean)} is + * Only use this way if {@link #showNavigationMenu(Activity, cgCache, cgeo.geocaching.Waypoint, Geopoint, boolean, boolean)} is * not suitable for the given usecase. * * @param menu @@ -235,7 +235,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { } } - public static void addMenuItems(final Menu menu, final cgWaypoint waypoint) { + public static void addMenuItems(final Menu menu, final Waypoint waypoint) { for (NavigationAppsEnum navApp : getInstalledNavigationApps()) { if (navApp.app instanceof WaypointNavigationApp) { WaypointNavigationApp waypointApp = (WaypointNavigationApp) navApp.app; @@ -267,13 +267,13 @@ public final class NavigationAppFactory extends AbstractAppFactory { } } - public static boolean onMenuItemSelected(final MenuItem item, Activity activity, cgWaypoint waypoint) { + public static boolean onMenuItemSelected(final MenuItem item, Activity activity, Waypoint waypoint) { final App menuItem = getAppFromMenuItem(item); navigateWaypoint(activity, waypoint, menuItem); return menuItem != null; } - private static void navigateWaypoint(Activity activity, cgWaypoint waypoint, App app) { + private static void navigateWaypoint(Activity activity, Waypoint waypoint, App app) { if (app instanceof WaypointNavigationApp) { WaypointNavigationApp waypointApp = (WaypointNavigationApp) app; waypointApp.navigate(activity, waypoint); @@ -327,7 +327,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * @param activity * @param waypoint */ - public static void startDefaultNavigationApplication(int defaultNavigation, Activity activity, cgWaypoint waypoint) { + public static void startDefaultNavigationApplication(int defaultNavigation, Activity activity, Waypoint waypoint) { if (waypoint == null || waypoint.getCoords() == null) { ActivityMixin.showToast(activity, cgeoapplication.getInstance().getString(R.string.err_location_unknown)); return; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java index a481813..c94c4f4 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.apps.AbstractApp; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.GeopointFormatter.Format; @@ -21,7 +21,7 @@ class RMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNaviga } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { navigate(activity, waypoint.getCoords(), waypoint.getLookup(), waypoint.getName()); } @@ -34,7 +34,7 @@ class RMapsApp extends AbstractApp implements CacheNavigationApp, WaypointNaviga } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return waypoint.getCoords() != null; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java index eb01f23..4c3b87e 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java @@ -1,8 +1,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; import android.app.Activity; @@ -18,7 +18,7 @@ class StaticMapApp extends AbstractStaticMapsApp { } @Override - public boolean isEnabled(cgWaypoint waypoint) { + public boolean isEnabled(Waypoint waypoint) { return hasStaticMap(waypoint); } @@ -28,7 +28,7 @@ class StaticMapApp extends AbstractStaticMapsApp { } @Override - public void navigate(Activity activity, cgWaypoint waypoint) { + public void navigate(Activity activity, Waypoint waypoint) { invokeStaticMaps(activity, null, waypoint, false); } } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java index 7d3a706..c26ec3e 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java @@ -1,6 +1,6 @@ package cgeo.geocaching.apps.cache.navi; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import android.app.Activity; @@ -9,7 +9,7 @@ import android.app.Activity; * */ public interface WaypointNavigationApp { - void navigate(final Activity activity, final cgWaypoint waypoint); + void navigate(final Activity activity, final Waypoint waypoint); - boolean isEnabled(final cgWaypoint waypoint); + boolean isEnabled(final Waypoint waypoint); } diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 919ad06..de35008 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -101,9 +101,9 @@ public class cgCache implements ICache, IWaypoint { return cgData.loadAttributes(geocode); } }; - private LazyInitializedList waypoints = new LazyInitializedList() { + private LazyInitializedList waypoints = new LazyInitializedList() { @Override - protected List loadFromDatabase() { + protected List loadFromDatabase() { return cgData.loadWaypoints(geocode); } }; @@ -146,7 +146,7 @@ public class cgCache implements ICache, IWaypoint { public cgCache(GPXParser gpxParser) { setReliableLatLon(true); setAttributes(Collections. emptyList()); - setWaypoints(Collections. emptyList(), false); + setWaypoints(Collections. emptyList(), false); setLogs(Collections. emptyList()); } @@ -295,8 +295,8 @@ public class cgCache implements ICache, IWaypoint { this.setWaypoints(other.waypoints.asList(), false); } else { - ArrayList newPoints = new ArrayList(waypoints.asList()); - cgWaypoint.mergeWayPoints(newPoints, other.waypoints.asList(), false); + ArrayList newPoints = new ArrayList(waypoints.asList()); + Waypoint.mergeWayPoints(newPoints, other.waypoints.asList(), false); this.setWaypoints(newPoints, false); } if (spoilers == null) { @@ -320,7 +320,7 @@ public class cgCache implements ICache, IWaypoint { // if cache has ORIGINAL type waypoint ... it is considered that it has modified coordinates, otherwise not userModifiedCoords = false; if (waypoints != null) { - for (cgWaypoint wpt : waypoints) { + for (Waypoint wpt : waypoints) { if (wpt.getWaypointType() == WaypointType.ORIGINAL) { userModifiedCoords = true; break; @@ -934,7 +934,7 @@ public class cgCache implements ICache, IWaypoint { * * @return always non null */ - public List getWaypoints() { + public List getWaypoints() { return waypoints.asList(); } @@ -946,11 +946,11 @@ public class cgCache implements ICache, IWaypoint { * called while loading or building a cache * @return true if waypoints successfully added to waypoint database */ - public boolean setWaypoints(List waypoints, boolean saveToDatabase) { + public boolean setWaypoints(List waypoints, boolean saveToDatabase) { this.waypoints.set(waypoints); finalDefined = false; if (waypoints != null) { - for (cgWaypoint waypoint : waypoints) { + for (Waypoint waypoint : waypoints) { waypoint.setGeocode(geocode); if (waypoint.isFinalWithCoords()) { finalDefined = true; @@ -1147,7 +1147,7 @@ public class cgCache implements ICache, IWaypoint { * called while loading or building a cache * @return true if waypoint successfully added to waypoint database */ - public boolean addOrChangeWaypoint(final cgWaypoint waypoint, boolean saveToDatabase) { + public boolean addOrChangeWaypoint(final Waypoint waypoint, boolean saveToDatabase) { waypoint.setGeocode(geocode); if (waypoint.getId() <= 0) { // this is a new waypoint @@ -1185,7 +1185,7 @@ public class cgCache implements ICache, IWaypoint { */ private void resetFinalDefined() { finalDefined = false; - for (cgWaypoint wp : waypoints) { + for (Waypoint wp : waypoints) { if (wp.isFinalWithCoords()) { finalDefined = true; break; @@ -1208,12 +1208,12 @@ public class cgCache implements ICache, IWaypoint { * the waypoint to duplicate * @return true if the waypoint was duplicated, false otherwise (invalid index) */ - public boolean duplicateWaypoint(final cgWaypoint original) { + public boolean duplicateWaypoint(final Waypoint original) { if (original == null) { return false; } final int index = getWaypointIndex(original); - final cgWaypoint copy = new cgWaypoint(original); + final Waypoint copy = new Waypoint(original); copy.setUserDefined(); copy.setName(cgeoapplication.getInstance().getString(R.string.waypoint_copy_of) + " " + copy.getName()); waypoints.add(index + 1, copy); @@ -1227,7 +1227,7 @@ public class cgCache implements ICache, IWaypoint { * to be removed from cache * @return true, if the waypoint was deleted */ - public boolean deleteWaypoint(final cgWaypoint waypoint) { + public boolean deleteWaypoint(final Waypoint waypoint) { if (waypoint == null) { return false; } @@ -1254,7 +1254,7 @@ public class cgCache implements ICache, IWaypoint { * @param waypoint */ - public void deleteWaypointForce(cgWaypoint waypoint) { + public void deleteWaypointForce(Waypoint waypoint) { final int index = getWaypointIndex(waypoint); waypoints.remove(index); cgData.deleteWaypoint(waypoint.getId()); @@ -1269,7 +1269,7 @@ public class cgCache implements ICache, IWaypoint { * to find index for * @return index in waypoints if found, -1 otherwise */ - private int getWaypointIndex(final cgWaypoint waypoint) { + private int getWaypointIndex(final Waypoint waypoint) { final int id = waypoint.getId(); for (int index = 0; index < waypoints.size(); index++) { if (waypoints.get(index).getId() == id) { @@ -1286,7 +1286,7 @@ public class cgCache implements ICache, IWaypoint { * the index of the waypoint * @return waypoint or null if index is out of range */ - public cgWaypoint getWaypoint(final int index) { + public Waypoint getWaypoint(final int index) { return index >= 0 && index < waypoints.size() ? waypoints.get(index) : null; } @@ -1297,8 +1297,8 @@ public class cgCache implements ICache, IWaypoint { * the id of the waypoint to look for * @return waypoint or null */ - public cgWaypoint getWaypointById(final int id) { - for (final cgWaypoint waypoint : waypoints) { + public Waypoint getWaypointById(final int id) { + for (final Waypoint waypoint : waypoints) { if (waypoint.getId() == id) { return waypoint; } @@ -1321,7 +1321,7 @@ public class cgCache implements ICache, IWaypoint { // coords must have non zero latitude and longitude and at least one part shall have fractional degrees if (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, false); + final Waypoint waypoint = new Waypoint(name, WaypointType.WAYPOINT, false); waypoint.setCoords(point); addOrChangeWaypoint(waypoint, false); count++; diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 23fdef9..1042959 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -1112,11 +1112,11 @@ public class cgData { String geocode = cache.getGeocode(); database.delete(dbTableWaypoints, "geocode = ? and type <> ? and own = 0", new String[]{geocode, "own"}); - List waypoints = cache.getWaypoints(); + List waypoints = cache.getWaypoints(); if (CollectionUtils.isNotEmpty(waypoints)) { ContentValues values = new ContentValues(); long timeStamp = System.currentTimeMillis(); - for (cgWaypoint oneWaypoint : waypoints) { + for (Waypoint oneWaypoint : waypoints) { if (oneWaypoint.isUserDefined()) { continue; } @@ -1171,7 +1171,7 @@ public class cgData { return new Geopoint(cursor.getDouble(indexLat), cursor.getDouble(indexLon)); } - private static boolean saveWaypointInternal(int id, String geocode, cgWaypoint waypoint) { + private static boolean saveWaypointInternal(int id, String geocode, Waypoint waypoint) { if ((StringUtils.isBlank(geocode) && id <= 0) || waypoint == null) { return false; } @@ -1473,7 +1473,7 @@ public class cgData { } if (loadFlags.contains(LoadFlag.LOAD_WAYPOINTS)) { - final List waypoints = loadWaypoints(cache.getGeocode()); + final List waypoints = loadWaypoints(cache.getGeocode()); if (CollectionUtils.isNotEmpty(waypoints)) { cache.setWaypoints(waypoints, false); } @@ -1683,7 +1683,7 @@ public class cgData { return attributes; } - public static cgWaypoint loadWaypoint(int id) { + public static Waypoint loadWaypoint(int id) { if (id == 0) { return null; } @@ -1702,21 +1702,21 @@ public class cgData { Log.d("cgData.loadWaypoint(" + id + ")"); - final cgWaypoint waypoint = cursor.moveToFirst() ? createWaypointFromDatabaseContent(cursor) : null; + final Waypoint waypoint = cursor.moveToFirst() ? createWaypointFromDatabaseContent(cursor) : null; cursor.close(); return waypoint; } - public static List loadWaypoints(final String geocode) { + public static List loadWaypoints(final String geocode) { if (StringUtils.isBlank(geocode)) { return null; } init(); - final List waypoints = new ArrayList(); + final List waypoints = new ArrayList(); final Cursor cursor = database.query( dbTableWaypoints, @@ -1737,11 +1737,11 @@ public class cgData { return waypoints; } - private static cgWaypoint createWaypointFromDatabaseContent(final Cursor cursor) { + private static Waypoint createWaypointFromDatabaseContent(final Cursor cursor) { final String name = cursor.getString(cursor.getColumnIndex("name")); final WaypointType type = WaypointType.findById(cursor.getString(cursor.getColumnIndex("type"))); final boolean own = cursor.getInt(cursor.getColumnIndex("own")) != 0; - final cgWaypoint waypoint = new cgWaypoint(name, type, own); + final Waypoint waypoint = new Waypoint(name, type, own); waypoint.setId(cursor.getInt(cursor.getColumnIndex("_id"))); waypoint.setGeocode(cursor.getString(cursor.getColumnIndex("geocode"))); @@ -2729,7 +2729,7 @@ public class cgData { * @return */ - public static Set loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) { + public static Set loadWaypoints(final Viewport viewport, boolean excludeMine, boolean excludeDisabled, CacheType type) { final StringBuilder where = new StringBuilder(buildCoordinateWhere(dbTableWaypoints, viewport)); if (excludeMine) { where.append(" and ").append(dbTableCaches).append(".own == 0 and ").append(dbTableCaches).append(".found == 0"); @@ -2748,7 +2748,7 @@ public class cgData { } query.append(" FROM ").append(dbTableWaypoints).append(", ").append(dbTableCaches).append(" WHERE ").append(dbTableWaypoints).append(".geocode == ").append(dbTableCaches).append(".geocode and ").append(where); - final Set waypoints = new HashSet(); + final Set waypoints = new HashSet(); final Cursor cursor = database.rawQuery(query.toString(), null); while (cursor.moveToNext()) { waypoints.add(createWaypointFromDatabaseContent(cursor)); @@ -2925,7 +2925,7 @@ public class cgData { return new SearchResult(geocodes, cgData.getAllHistoryCachesCount()); } - public static boolean saveWaypoint(int id, String geocode, cgWaypoint waypoint) { + public static boolean saveWaypoint(int id, String geocode, Waypoint waypoint) { if (cgData.saveWaypointInternal(id, geocode, waypoint)) { cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); return true; diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java deleted file mode 100644 index 4b7b95e..0000000 --- a/main/src/cgeo/geocaching/cgWaypoint.java +++ /dev/null @@ -1,245 +0,0 @@ -package cgeo.geocaching; - -import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; - -import org.apache.commons.lang3.StringUtils; - -import android.content.res.Resources; -import android.widget.TextView; - -import java.util.List; - -public class cgWaypoint implements IWaypoint, Comparable { - - public static final String PREFIX_OWN = "OWN"; - private static final int ORDER_UNDEFINED = -2; - private int id = 0; - private String geocode = "geocode"; - private WaypointType waypointType = WaypointType.WAYPOINT; - private String prefix = ""; - private String lookup = ""; - private String name = ""; - private String latlon = ""; - private Geopoint coords = null; - private String note = ""; - private int cachedOrder = ORDER_UNDEFINED; - private boolean own = false; - - /** - * require name and type for every waypoint - * - * @param name - * @param type - */ - public cgWaypoint(final String name, final WaypointType type, final boolean own) { - this.name = name; - this.waypointType = type; - this.own = own; - } - - /** - * copy constructor - * - * @param other - */ - public cgWaypoint(final cgWaypoint other) { - merge(other); - this.waypointType = other.waypointType; - id = 0; - } - - public void setIcon(final Resources res, final TextView nameView) { - nameView.setCompoundDrawablesWithIntrinsicBounds(res.getDrawable(waypointType.markerId), null, null, null); - } - - public void merge(final cgWaypoint old) { - if (StringUtils.isBlank(prefix)) { - setPrefix(old.prefix); - } - if (StringUtils.isBlank(lookup)) { - lookup = old.lookup; - } - if (StringUtils.isBlank(name)) { - setName(old.name); - } - if (StringUtils.isBlank(latlon) || latlon.startsWith("?")) { // there are waypoints containing "???" - latlon = old.latlon; - } - if (coords == null) { - coords = old.coords; - } - if (StringUtils.isBlank(note)) { - note = old.note; - } - if (note != null && old.note != null) { - if (old.note.length() > note.length()) { - note = old.note; - } - } - } - - public static void mergeWayPoints(List newPoints, - List oldPoints, boolean forceMerge) { - // copy user modified details of the waypoints - if (newPoints != null && oldPoints != null) { - for (cgWaypoint old : oldPoints) { - if (old != null) { - boolean merged = false; - if (StringUtils.isNotEmpty(old.name)) { - for (cgWaypoint waypoint : newPoints) { - if (waypoint != null && waypoint.name != null) { - if (old.name.equalsIgnoreCase(waypoint.name)) { - waypoint.merge(old); - merged = true; - break; - } - } - } - } - // user added waypoints should also be in the new list - if (!merged && (old.isUserDefined() || forceMerge)) { - newPoints.add(old); - } - } - } - } - } - - public boolean isUserDefined() { - return own || WaypointType.OWN == waypointType; - } - - public void setUserDefined() { - own = true; - setPrefix(PREFIX_OWN); - } - - private int computeOrder() { - switch (waypointType) { - case PARKING: - return -1; - case TRAILHEAD: - return 1; - case STAGE: // puzzles and stages with same value - return 2; - case PUZZLE: - return 2; - case FINAL: - return 3; - case OWN: - return 4; - default: - return 0; - } - } - - private int order() { - if (cachedOrder == ORDER_UNDEFINED) { - cachedOrder = computeOrder(); - } - return cachedOrder; - } - - @Override - public int compareTo(cgWaypoint other) { - return order() - other.order(); - } - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - cachedOrder = ORDER_UNDEFINED; - } - - public String getUrl() { - return "http://www.geocaching.com//seek/cache_details.aspx?wp=" + geocode; - } - - @Override - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - public String getGeocode() { - return geocode; - } - - public void setGeocode(String geocode) { - this.geocode = StringUtils.upperCase(geocode); - } - - @Override - public WaypointType getWaypointType() { - return waypointType; - } - - public String getLookup() { - return lookup; - } - - public void setLookup(String lookup) { - this.lookup = lookup; - } - - @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getLatlon() { - return latlon; - } - - public void setLatlon(String latlon) { - this.latlon = latlon; - } - - @Override - public Geopoint getCoords() { - return coords; - } - - public void setCoords(Geopoint coords) { - this.coords = coords; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } - - @Override - public String toString() { - 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 == waypointType && null != coords; - } - - @Override - public String getCoordType() { - return "waypoint"; - } -} diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index c42008b..323d65c 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -5,11 +5,11 @@ import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.TrackableLog; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgData; import cgeo.geocaching.cgImage; import cgeo.geocaching.cgTrackable; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; @@ -611,14 +611,14 @@ public abstract class GCParser { } // waypoints - reset collection - cache.setWaypoints(Collections. emptyList(), false); + cache.setWaypoints(Collections. emptyList(), false); // add waypoint for original coordinates in case of user-modified listing-coordinates try { final String originalCoords = BaseUtils.getMatch(page, GCConstants.PATTERN_LATLON_ORIG, false, null); if (null != originalCoords) { - final cgWaypoint waypoint = new cgWaypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false); + final Waypoint waypoint = new Waypoint(cgeoapplication.getInstance().getString(R.string.cache_coordinates_original), WaypointType.ORIGINAL, false); waypoint.setCoords(new Geopoint(originalCoords)); cache.addOrChangeWaypoint(waypoint, false); cache.setUserModifiedCoords(true); @@ -662,7 +662,7 @@ public abstract class GCParser { // waypoint type final String resulttype = BaseUtils.getMatch(wp[3], GCConstants.PATTERN_WPTYPE, null); - final cgWaypoint waypoint = new cgWaypoint(name, WaypointType.findById(resulttype), false); + final Waypoint waypoint = new Waypoint(name, WaypointType.findById(resulttype), false); // waypoint prefix waypoint.setPrefix(BaseUtils.getMatch(wp[4], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, true, 2, waypoint.getPrefix(), false)); diff --git a/main/src/cgeo/geocaching/export/GpxExport.java b/main/src/cgeo/geocaching/export/GpxExport.java index 3aec114..9f6642f 100644 --- a/main/src/cgeo/geocaching/export/GpxExport.java +++ b/main/src/cgeo/geocaching/export/GpxExport.java @@ -3,9 +3,9 @@ package cgeo.geocaching.export; import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; import cgeo.geocaching.Settings; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgData; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.activity.Progress; import cgeo.geocaching.enumerations.CacheAttribute; @@ -282,10 +282,10 @@ class GpxExport extends AbstractExport { } private void writeWaypoints(final cgCache cache) throws IOException { - List waypoints = cache.getWaypoints(); - List ownWaypoints = new ArrayList(waypoints.size()); - List originWaypoints = new ArrayList(waypoints.size()); - for (cgWaypoint wp : cache.getWaypoints()) { + List waypoints = cache.getWaypoints(); + List ownWaypoints = new ArrayList(waypoints.size()); + List originWaypoints = new ArrayList(waypoints.size()); + for (Waypoint wp : cache.getWaypoints()) { if (wp.isUserDefined()) { ownWaypoints.add(wp); } else { @@ -293,7 +293,7 @@ class GpxExport extends AbstractExport { } } int maxPrefix = 0; - for (cgWaypoint wp : originWaypoints) { + for (Waypoint wp : originWaypoints) { String prefix = wp.getPrefix(); try { maxPrefix = Math.max(Integer.parseInt(prefix), maxPrefix); @@ -302,7 +302,7 @@ class GpxExport extends AbstractExport { } writeCacheWaypoint(wp, prefix); } - for (cgWaypoint wp : ownWaypoints) { + for (Waypoint wp : ownWaypoints) { maxPrefix++; String prefix = StringUtils.leftPad(String.valueOf(maxPrefix), 2, '0'); writeCacheWaypoint(wp, prefix); @@ -318,7 +318,7 @@ class GpxExport extends AbstractExport { * @param prefix * @throws IOException */ - private void writeCacheWaypoint(final cgWaypoint wp, final String prefix) throws IOException { + private void writeCacheWaypoint(final Waypoint wp, final String prefix) throws IOException { gpx.write(" mergedWayPoints = new ArrayList(); + final ArrayList mergedWayPoints = new ArrayList(); mergedWayPoints.addAll(cacheForWaypoint.getWaypoints()); - final ArrayList newPoints = new ArrayList(); + final ArrayList newPoints = new ArrayList(); newPoints.add(waypoint); - cgWaypoint.mergeWayPoints(newPoints, mergedWayPoints, true); + Waypoint.mergeWayPoints(newPoints, mergedWayPoints, true); cacheForWaypoint.setWaypoints(newPoints, false); cgData.saveCache(cacheForWaypoint, EnumSet.of(SaveFlag.SAVE_DB)); showProgressMessage(progressHandler, progressStream.getProgress()); diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 356f763..a470672 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -8,9 +8,9 @@ import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.StoredList; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgData; -import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.cgeocaches; import cgeo.geocaching.activity.ActivityMixin; @@ -180,7 +180,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto /** List of caches in the viewport */ private LeastRecentlyUsedSet caches = null; /** List of waypoints in the viewport */ - private final LeastRecentlyUsedSet waypoints = new LeastRecentlyUsedSet(MAX_CACHES); + private final LeastRecentlyUsedSet waypoints = new LeastRecentlyUsedSet(MAX_CACHES); // storing for offline private ProgressDialog waitDialog = null; private int detailTotal = 0; @@ -1156,7 +1156,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (isLiveEnabled || mapMode == MapMode.COORDS) { //All visible waypoints CacheType type = Settings.getCacheType(); - Set waypointsInViewport = cgData.loadWaypoints(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches(), type); + Set waypointsInViewport = cgData.loadWaypoints(viewport, Settings.isExcludeMyCaches(), Settings.isExcludeDisabledCaches(), type); waypoints.addAll(waypointsInViewport); } else @@ -1261,14 +1261,14 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto // display caches final List cachesToDisplay = caches.getAsList(); - final List waypointsToDisplay = new ArrayList(waypoints); + final List waypointsToDisplay = new ArrayList(waypoints); final List itemsToDisplay = new ArrayList(); if (!cachesToDisplay.isEmpty()) { // Only show waypoints for single view or setting // when less than showWaypointsthreshold Caches shown if (mapMode == MapMode.SINGLE || (cachesCnt < Settings.getWayPointsThreshold())) { - for (cgWaypoint waypoint : waypointsToDisplay) { + for (Waypoint waypoint : waypointsToDisplay) { if (waypoint == null || waypoint.getCoords() == null) { continue; @@ -1316,7 +1316,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } if (coordsIntent != null) { - final cgWaypoint waypoint = new cgWaypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false); + final Waypoint waypoint = new Waypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false); waypoint.setCoords(coordsIntent); final CachesOverlayItemImpl item = getItem(waypoint, null, waypoint); @@ -1626,7 +1626,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto * Waypoint. Mutally exclusive with cache * @return */ - private CachesOverlayItemImpl getItem(final IWaypoint coord, final cgCache cache, final cgWaypoint waypoint) { + private CachesOverlayItemImpl getItem(final IWaypoint coord, final cgCache cache, final Waypoint waypoint) { if (cache != null) { final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(coord, cache.getType()); diff --git a/main/src/cgeo/geocaching/ui/Formatter.java b/main/src/cgeo/geocaching/ui/Formatter.java index 60fb3e6..4d23952 100644 --- a/main/src/cgeo/geocaching/ui/Formatter.java +++ b/main/src/cgeo/geocaching/ui/Formatter.java @@ -2,7 +2,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgWaypoint; +import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheListType; import cgeo.geocaching.enumerations.CacheSize; @@ -152,13 +152,13 @@ public abstract class Formatter { return StringUtils.join(infos, Formatter.SEPARATOR); } - public static String formatWaypointInfo(cgWaypoint waypoint) { + public static String formatWaypointInfo(Waypoint waypoint) { final List infos = new ArrayList(3); WaypointType waypointType = waypoint.getWaypointType(); if (waypointType != WaypointType.OWN && waypointType != null) { infos.add(waypointType.getL10n()); } - if (cgWaypoint.PREFIX_OWN.equalsIgnoreCase(waypoint.getPrefix())) { + if (Waypoint.PREFIX_OWN.equalsIgnoreCase(waypoint.getPrefix())) { infos.add(cgeoapplication.getInstance().getString(R.string.waypoint_custom)); } else { if (StringUtils.isNotBlank(waypoint.getPrefix())) { -- cgit v1.1