From 06608af852274ce5c394e647795c1763e2509080 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 27 Nov 2012 08:27:35 +0100 Subject: fix #2202: logs duplicated after importing GPX twice --- main/src/cgeo/geocaching/cgCache.java | 23 ++++++++++++++++++++++- main/src/cgeo/geocaching/files/GPXParser.java | 5 +---- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index bb167bd..7035d65 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -19,6 +19,7 @@ import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.WaypointType; +import cgeo.geocaching.files.GPXParser; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.utils.CancellableHandler; @@ -130,6 +131,26 @@ public class cgCache implements ICache, IWaypoint { private Handler changeNotificationHandler = null; + /** + * Create a new cache. To be used everywhere except for the GPX parser + */ + public cgCache() { + // empty + } + + /** + * Cache constructor to be used by the GPX parser only. This constructor explicitly sets several members to empty + * lists. + * + * @param gpxParser + */ + public cgCache(GPXParser gpxParser) { + setReliableLatLon(true); + setAttributes(Collections. emptyList()); + setWaypoints(Collections. emptyList(), false); + setLogs(Collections. emptyList()); + } + public void setChangeNotificationHandler(Handler newNotificationHandler) { changeNotificationHandler = newNotificationHandler; } @@ -1612,4 +1633,4 @@ public class cgCache implements ICache, IWaypoint { } return result; } -} \ No newline at end of file +} diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index 221aa1e..b9d3f53 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -854,10 +854,7 @@ public abstract class GPXParser extends FileParser { desc = null; cmt = null; - cache = new cgCache(); - cache.setReliableLatLon(true); - cache.setAttributes(new ArrayList()); - cache.setWaypoints(new ArrayList(), false); + cache = new cgCache(this); for (int i = 0; i < userData.length; i++) { userData[i] = null; } -- cgit v1.1