aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCConstants.java2
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java2
-rw-r--r--main/src/cgeo/geocaching/enumerations/CacheType.java12
3 files changed, 14 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConstants.java b/main/src/cgeo/geocaching/connector/gc/GCConstants.java
index 5ee8993..305ac6f 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCConstants.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCConstants.java
@@ -47,7 +47,7 @@ public final class GCConstants {
public final static Pattern PATTERN_FOUND_ALTERNATIVE = Pattern.compile("<div class=\"StatusInformationWidget FavoriteWidget\"");
public final static Pattern PATTERN_FOUND_DATE = Pattern.compile(">Logged on: ([^<]+?)<");
public final static Pattern PATTERN_OWNER_DISPLAYNAME = Pattern.compile("<div id=\"ctl00_ContentBody_mcd1\">[^<]+<a href=\"[^\"]+\">([^<]+)</a>");
- public final static Pattern PATTERN_TYPE = Pattern.compile("<img src=\"[^\"]*/WptTypes/\\d+\\.gif\" alt=\"([^\"]+?)\"[^>]*>");
+ public final static Pattern PATTERN_TYPE = Pattern.compile("<a href=\"/seek/nearest.aspx\\?tx=([0-9a-f-]+)");
public final static Pattern PATTERN_HIDDEN = Pattern.compile("<div id=\"ctl00_ContentBody_mcd2\">\\W*Hidden[\\s:]*([^<]+?)</div>");
public final static Pattern PATTERN_HIDDENEVENT = Pattern.compile("Event\\s*Date\\s*:\\s*([^<]+)<div id=\"calLinks\">", Pattern.DOTALL);
public final static Pattern PATTERN_FAVORITE = Pattern.compile("<div id=\"pnlFavoriteCache\">"); // without 'class="hideMe"' inside the tag !
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 0549b3f..5422c11 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -488,7 +488,7 @@ public abstract class GCParser {
cache.setFound(TextUtils.matches(page, GCConstants.PATTERN_FOUND) || TextUtils.matches(page, GCConstants.PATTERN_FOUND_ALTERNATIVE));
// cache type
- cache.setType(CacheType.getByPattern(TextUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType().id)));
+ cache.setType(CacheType.getByGuid(TextUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType().id)));
// on watchlist
cache.setOnWatchlist(TextUtils.matches(page, GCConstants.PATTERN_WATCHLIST));
diff --git a/main/src/cgeo/geocaching/enumerations/CacheType.java b/main/src/cgeo/geocaching/enumerations/CacheType.java
index 506c791..535bfab 100644
--- a/main/src/cgeo/geocaching/enumerations/CacheType.java
+++ b/main/src/cgeo/geocaching/enumerations/CacheType.java
@@ -58,15 +58,19 @@ public enum CacheType {
private final static Map<String, CacheType> FIND_BY_ID;
private final static Map<String, CacheType> FIND_BY_PATTERN;
+ private final static Map<String, CacheType> FIND_BY_GUID;
static {
final HashMap<String, CacheType> mappingId = new HashMap<String, CacheType>();
final HashMap<String, CacheType> mappingPattern = new HashMap<String, CacheType>();
+ final HashMap<String, CacheType> mappingGuid = new HashMap<String, CacheType>();
for (CacheType ct : values()) {
mappingId.put(ct.id, ct);
mappingPattern.put(ct.pattern.toLowerCase(Locale.US), ct);
+ mappingGuid.put(ct.guid, ct);
}
FIND_BY_ID = Collections.unmodifiableMap(mappingId);
FIND_BY_PATTERN = Collections.unmodifiableMap(mappingPattern);
+ FIND_BY_GUID = Collections.unmodifiableMap(mappingGuid);
}
public static CacheType getById(final String id) {
@@ -85,6 +89,14 @@ public enum CacheType {
return result;
}
+ public static CacheType getByGuid(final String id) {
+ final CacheType result = (id != null) ? CacheType.FIND_BY_GUID.get(id) : null;
+ if (result == null) {
+ return UNKNOWN;
+ }
+ return result;
+ }
+
public final String getL10n() {
return CgeoApplication.getInstance().getBaseContext().getResources().getString(stringId);
}