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.java66
1 files changed, 39 insertions, 27 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 053c248..2ca505d 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -44,6 +44,7 @@ import android.net.Uri;
import android.text.Html;
import android.text.Spannable;
import android.text.Spanned;
+import android.text.style.ForegroundColorSpan;
import android.text.style.StrikethroughSpan;
import java.net.URLDecoder;
@@ -225,6 +226,9 @@ public abstract class GCParser {
if (cache.isDisabled() || cache.isArchived()) { // strike
cache.getNameSp().setSpan(new StrikethroughSpan(), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
+ if (cache.isArchived()) {
+ cache.getNameSp().setSpan(new ForegroundColorSpan(cgeoapplication.getInstance().getResources().getColor(R.color.archived_cache_color)), 0, cache.getNameSp().toString().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
}
searchResult.addCache(cache);
@@ -378,9 +382,9 @@ public abstract class GCParser {
cache.setName(cacheName);
// owner real name
- cache.setOwnerReal(URLDecoder.decode(BaseUtils.getMatch(page, GCConstants.PATTERN_OWNERREAL, true, cache.getOwnerReal())));
+ cache.setOwnerUserId(URLDecoder.decode(BaseUtils.getMatch(page, GCConstants.PATTERN_OWNER_USERID, true, cache.getOwnerUserId())));
- cache.setOwn(StringUtils.equalsIgnoreCase(cache.getOwnerReal(), Settings.getUsername()));
+ cache.setOwn(StringUtils.equalsIgnoreCase(cache.getOwnerUserId(), Settings.getUsername()));
String tableInside = page;
@@ -406,7 +410,7 @@ public abstract class GCParser {
}
// owner
- cache.setOwner(StringEscapeUtils.unescapeHtml4(BaseUtils.getMatch(tableInside, GCConstants.PATTERN_OWNER, true, cache.getOwner())).toString());
+ cache.setOwnerDisplayName(StringEscapeUtils.unescapeHtml4(BaseUtils.getMatch(tableInside, GCConstants.PATTERN_OWNER_DISPLAYNAME, true, cache.getOwnerDisplayName())));
// hidden
try {
@@ -436,6 +440,17 @@ public abstract class GCParser {
// cache found
cache.setFound(BaseUtils.matches(page, GCConstants.PATTERN_FOUND) || BaseUtils.matches(page, GCConstants.PATTERN_FOUND_ALTERNATIVE));
+ // cache found date
+ try {
+ final String foundDateString = BaseUtils.getMatch(page, GCConstants.PATTERN_FOUND_DATE, true, null);
+ if (StringUtils.isNotBlank(foundDateString)) {
+ cache.setVisitedDate(Login.parseGcCustomDate(foundDateString).getTime());
+ }
+ } catch (ParseException e) {
+ // failed to parse cache found date
+ Log.w("GCParser.parseCache: Failed to parse cache found date");
+ }
+
// cache type
cache.setType(CacheType.getByPattern(BaseUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType().id)));
@@ -508,35 +523,32 @@ public abstract class GCParser {
// cache spoilers
try {
- final String spoilers = BaseUtils.getMatch(page, GCConstants.PATTERN_SPOILERS, false, null);
- if (null != spoilers) {
- if (CancellableHandler.isCancelled(handler)) {
- return null;
- }
- CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_spoilers);
+ if (CancellableHandler.isCancelled(handler)) {
+ return null;
+ }
+ CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_spoilers);
- final Matcher matcherSpoilersInside = GCConstants.PATTERN_SPOILERSINSIDE.matcher(spoilers);
+ final Matcher matcherSpoilersInside = GCConstants.PATTERN_SPOILER_IMAGE.matcher(page);
- while (matcherSpoilersInside.find()) {
- // the original spoiler URL (include .../display/... contains a low-resolution image
- // if we shorten the URL we get the original-resolution image
- String url = matcherSpoilersInside.group(1).replace("/display", "");
+ while (matcherSpoilersInside.find()) {
+ // the original spoiler URL (include .../display/... contains a low-resolution image
+ // if we shorten the URL we get the original-resolution image
+ String url = matcherSpoilersInside.group(1).replace("/display", "");
- String title = null;
- if (matcherSpoilersInside.group(2) != null) {
- title = matcherSpoilersInside.group(2);
- }
- String description = null;
- if (matcherSpoilersInside.group(3) != null) {
- description = matcherSpoilersInside.group(3);
- }
- final cgImage spoiler = new cgImage(url, title, description);
+ String title = null;
+ if (matcherSpoilersInside.group(2) != null) {
+ title = matcherSpoilersInside.group(2);
+ }
+ String description = null;
+ if (matcherSpoilersInside.group(3) != null) {
+ description = matcherSpoilersInside.group(3);
+ }
+ final cgImage spoiler = new cgImage(url, title, description);
- if (cache.getSpoilers() == null) {
- cache.setSpoilers(new ArrayList<cgImage>());
- }
- cache.getSpoilers().add(spoiler);
+ if (cache.getSpoilers() == null) {
+ cache.setSpoilers(new ArrayList<cgImage>());
}
+ cache.getSpoilers().add(spoiler);
}
} catch (Exception e) {
// failed to parse cache spoilers