aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc/GCParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc/GCParser.java')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java54
1 files changed, 24 insertions, 30 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index e8de993..23102c9 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.connector.gc;
+import cgeo.geocaching.Geocache;
import cgeo.geocaching.Image;
import cgeo.geocaching.LogEntry;
import cgeo.geocaching.R;
@@ -8,7 +9,6 @@ import cgeo.geocaching.Settings;
import cgeo.geocaching.Trackable;
import cgeo.geocaching.TrackableLog;
import cgeo.geocaching.Waypoint;
-import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgData;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.enumerations.CacheSize;
@@ -30,7 +30,6 @@ import cgeo.geocaching.ui.DirectionImage;
import cgeo.geocaching.utils.BaseUtils;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.HtmlUtils;
-import cgeo.geocaching.utils.LazyInitializedList;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.MatcherWrapper;
@@ -122,7 +121,7 @@ public abstract class GCParser {
final int rows_count = rows.length;
for (int z = 1; z < rows_count; z++) {
- final cgCache cache = new cgCache();
+ final Geocache cache = new Geocache();
String row = rows[z];
// check for cache type presence
@@ -203,9 +202,6 @@ public abstract class GCParser {
// found it
cache.setFound(row.contains("/images/icons/16/found.png"));
- // own it
- cache.setOwn(row.contains("/images/icons/16/placed.png"));
-
// id
String result = BaseUtils.getMatch(row, GCConstants.PATTERN_SEARCH_ID, null);
if (null != result) {
@@ -293,8 +289,8 @@ public abstract class GCParser {
// get direction images
if (Settings.getLoadDirImg()) {
- final Set<cgCache> caches = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
- for (cgCache cache : caches) {
+ final Set<Geocache> caches = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB);
+ for (Geocache cache : caches) {
if (cache.getCoords() == null && StringUtils.isNotEmpty(cache.getDirectionImg())) {
DirectionImage.getDrawable(cache.getGeocode(), cache.getDirectionImg());
}
@@ -307,7 +303,7 @@ public abstract class GCParser {
static SearchResult parseCache(final String page, final CancellableHandler handler) {
final SearchResult searchResult = parseCacheFromText(page, handler);
if (searchResult != null && !searchResult.getGeocodes().isEmpty()) {
- final cgCache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ final Geocache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
getExtraOnlineInfo(cache, page, handler);
cache.setDetailedUpdatedNow();
if (CancellableHandler.isCancelled(handler)) {
@@ -351,7 +347,7 @@ public abstract class GCParser {
return searchResult;
}
- final cgCache cache = new cgCache();
+ final Geocache cache = new Geocache();
cache.setDisabled(page.contains(GCConstants.STRING_DISABLED));
cache.setArchived(page.contains(GCConstants.STRING_ARCHIVED));
@@ -375,8 +371,6 @@ public abstract class GCParser {
// owner real name
cache.setOwnerUserId(Network.decode(BaseUtils.getMatch(page, GCConstants.PATTERN_OWNER_USERID, true, cache.getOwnerUserId())));
- cache.setOwn(StringUtils.equalsIgnoreCase(cache.getOwnerUserId(), Settings.getUsername()));
-
cache.setUserModifiedCoords(false);
String tableInside = page;
@@ -463,10 +457,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);
@@ -474,7 +468,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);
@@ -492,7 +486,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, ""));
@@ -674,7 +668,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));
@@ -752,7 +746,7 @@ public abstract class GCParser {
}
// search results don't need to be filtered so load GCVote ratings here
- GCVote.loadRatings(new ArrayList<cgCache>(searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB)));
+ GCVote.loadRatings(new ArrayList<Geocache>(searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB)));
// save to application
search.setError(searchResult.getError());
@@ -1199,7 +1193,7 @@ public abstract class GCParser {
* the cache to add
* @return <code>false</code> if an error occurred, <code>true</code> otherwise
*/
- static boolean addToWatchlist(final cgCache cache) {
+ static boolean addToWatchlist(final Geocache cache) {
final String uri = "http://www.geocaching.com/my/watchlist.aspx?w=" + cache.getCacheId();
String page = Login.postRequestLogged(uri, null);
@@ -1225,7 +1219,7 @@ public abstract class GCParser {
* the cache to remove
* @return <code>false</code> if an error occurred, <code>true</code> otherwise
*/
- static boolean removeFromWatchlist(final cgCache cache) {
+ static boolean removeFromWatchlist(final Geocache cache) {
final String uri = "http://www.geocaching.com/my/watchlist.aspx?ds=1&action=rem&id=" + cache.getCacheId();
String page = Login.postRequestLogged(uri, null);
@@ -1274,11 +1268,11 @@ public abstract class GCParser {
* the cache to add
* @return <code>false</code> if an error occurred, <code>true</code> otherwise
*/
- static boolean addToFavorites(final cgCache cache) {
+ static boolean addToFavorites(final Geocache cache) {
return changeFavorite(cache, true);
}
- private static boolean changeFavorite(final cgCache cache, final boolean add) {
+ private static boolean changeFavorite(final Geocache cache, final boolean add) {
final String page = requestHtmlPage(cache.getGeocode(), null, "n", "0");
final String userToken = BaseUtils.getMatch(page, GCConstants.PATTERN_USERTOKEN, "");
if (StringUtils.isEmpty(userToken)) {
@@ -1308,7 +1302,7 @@ public abstract class GCParser {
* the cache to remove
* @return <code>false</code> if an error occurred, <code>true</code> otherwise
*/
- static boolean removeFromFavorites(final cgCache cache) {
+ static boolean removeFromFavorites(final Geocache cache) {
return changeFavorite(cache, false);
}
@@ -1510,7 +1504,7 @@ public abstract class GCParser {
* @param friends
* retrieve friend logs
*/
- private static List<LogEntry> loadLogsFromDetails(final String page, final cgCache cache, final boolean friends, final boolean getDataFromPage) {
+ private static List<LogEntry> loadLogsFromDetails(final String page, final Geocache cache, final boolean friends, final boolean getDataFromPage) {
String rawResponse;
if (!getDataFromPage) {
@@ -1697,7 +1691,7 @@ public abstract class GCParser {
params.put("tx", cacheType.guid);
}
- private static void getExtraOnlineInfo(final cgCache cache, final String page, final CancellableHandler handler) {
+ private static void getExtraOnlineInfo(final Geocache cache, final String page, final CancellableHandler handler) {
if (CancellableHandler.isCancelled(handler)) {
return;
}
@@ -1705,7 +1699,7 @@ public abstract class GCParser {
//cache.setLogs(loadLogsFromDetails(page, cache, false));
if (Settings.isFriendLogsWanted()) {
CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_logs);
- LazyInitializedList<LogEntry> allLogs = cache.getLogs();
+ List<LogEntry> allLogs = cache.getLogs();
List<LogEntry> friendLogs = loadLogsFromDetails(page, cache, true, false);
if (friendLogs != null) {
for (LogEntry log : friendLogs) {
@@ -1742,15 +1736,15 @@ public abstract class GCParser {
}
}
- public static boolean uploadModifiedCoordinates(cgCache cache, Geopoint wpt) {
+ public static boolean uploadModifiedCoordinates(Geocache cache, Geopoint wpt) {
return editModifiedCoordinates(cache, wpt);
}
- public static boolean deleteModifiedCoordinates(cgCache cache) {
+ public static boolean deleteModifiedCoordinates(Geocache cache) {
return editModifiedCoordinates(cache, null);
}
- public static boolean editModifiedCoordinates(cgCache cache, Geopoint wpt) {
+ public static boolean editModifiedCoordinates(Geocache cache, Geopoint wpt) {
final String page = requestHtmlPage(cache.getGeocode(), null, "n", "0");
final String userToken = BaseUtils.getMatch(page, GCConstants.PATTERN_USERTOKEN, "");
if (StringUtils.isEmpty(userToken)) {