diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-02-14 22:20:16 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-02-14 22:20:16 +0100 |
| commit | 7106273249ed67a1e95ce8e5c1acf49b583ce190 (patch) | |
| tree | 6d8c5cf3a8861cbed071b0527f2ef473c541d8db /main/src/cgeo/geocaching/connector | |
| parent | daadd2fee87366d475f0936b838c72bf0f9be2b0 (diff) | |
| download | cgeo-7106273249ed67a1e95ce8e5c1acf49b583ce190.zip cgeo-7106273249ed67a1e95ce8e5c1acf49b583ce190.tar.gz cgeo-7106273249ed67a1e95ce8e5c1acf49b583ce190.tar.bz2 | |
reduce memory usage for cache lists
* lazily load some of the strings in caches
* remove latlon, it was never used except in parsing itself
* change some collection handling to avoid huge memory hogs
Diffstat (limited to 'main/src/cgeo/geocaching/connector')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 15 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java | 2 |
2 files changed, 8 insertions, 9 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 2117053..5481b0c 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -1,6 +1,7 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.Geocache; +import cgeo.geocaching.Image; import cgeo.geocaching.LogEntry; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; @@ -9,7 +10,6 @@ import cgeo.geocaching.Trackable; import cgeo.geocaching.TrackableLog; import cgeo.geocaching.Waypoint; import cgeo.geocaching.cgData; -import cgeo.geocaching.Image; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; @@ -29,7 +29,6 @@ import cgeo.geocaching.network.Parameters; import cgeo.geocaching.ui.DirectionImage; import cgeo.geocaching.utils.BaseUtils; import cgeo.geocaching.utils.CancellableHandler; -import cgeo.geocaching.utils.LazyInitializedList; import cgeo.geocaching.utils.Log; import cgeo.geocaching.utils.MatcherWrapper; @@ -455,10 +454,10 @@ public abstract class GCParser { cache.setOnWatchlist(BaseUtils.matches(page, GCConstants.PATTERN_WATCHLIST)); // latitude and longitude. Can only be retrieved if user is logged in - cache.setLatlon(BaseUtils.getMatch(page, GCConstants.PATTERN_LATLON, true, cache.getLatlon())); - if (StringUtils.isNotEmpty(cache.getLatlon())) { + String latlon = BaseUtils.getMatch(page, GCConstants.PATTERN_LATLON, true, ""); + if (StringUtils.isNotEmpty(latlon)) { try { - cache.setCoords(new Geopoint(cache.getLatlon())); + cache.setCoords(new Geopoint(latlon)); cache.setReliableLatLon(true); } catch (Geopoint.GeopointException e) { Log.w("GCParser.parseCache: Failed to parse cache coordinates", e); @@ -466,7 +465,7 @@ public abstract class GCParser { } // cache location - cache.setLocation(BaseUtils.getMatch(page, GCConstants.PATTERN_LOCATION, true, cache.getLocation())); + cache.setLocation(BaseUtils.getMatch(page, GCConstants.PATTERN_LOCATION, true, "")); // cache hint String result = BaseUtils.getMatch(page, GCConstants.PATTERN_HINT, false, null); @@ -484,7 +483,7 @@ public abstract class GCParser { cache.setPersonalNote(BaseUtils.getMatch(page, GCConstants.PATTERN_PERSONALNOTE, true, cache.getPersonalNote())); // cache short description - cache.setShortdesc(BaseUtils.getMatch(page, GCConstants.PATTERN_SHORTDESC, true, cache.getShortdesc())); + cache.setShortDescription(BaseUtils.getMatch(page, GCConstants.PATTERN_SHORTDESC, true, "")); // cache description cache.setDescription(BaseUtils.getMatch(page, GCConstants.PATTERN_DESC, true, "")); @@ -666,7 +665,7 @@ public abstract class GCParser { waypoint.setLookup(BaseUtils.getMatch(wp[5], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, true, 2, waypoint.getLookup(), false)); // waypoint latitude and logitude - String latlon = Html.fromHtml(BaseUtils.getMatch(wp[7], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, false, 2, "", false)).toString().trim(); + latlon = Html.fromHtml(BaseUtils.getMatch(wp[7], GCConstants.PATTERN_WPPREFIXORLOOKUPORLATLON, false, 2, "", false)).toString().trim(); if (!StringUtils.startsWith(latlon, "???")) { waypoint.setLatlon(latlon); waypoint.setCoords(new Geopoint(latlon)); diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java index a9c041c..e44b0a5 100644 --- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java +++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java @@ -464,7 +464,7 @@ public class OC11XMLParser { public void end() { final Geocache cache = caches.get(descHolder.cacheId); if (cache != null) { - cache.setShortdesc(descHolder.shortDesc); + cache.setShortDescription(descHolder.shortDesc); cache.setDescription(cache.getDescription() + descHolder.desc); cache.setHint(descHolder.hint); } |
