From 0726be7130feda75973101aa8ff94eaf80163fcc Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Tue, 7 May 2013 20:03:29 +0200 Subject: refactoring: simplify log types handling --- main/src/cgeo/geocaching/Geocache.java | 4 +--- main/src/cgeo/geocaching/VisitCacheActivity.java | 1 - main/src/cgeo/geocaching/connector/gc/GCParser.java | 14 +++++--------- 3 files changed, 6 insertions(+), 13 deletions(-) (limited to 'main') diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 705f2ed..fe5de91 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -47,7 +47,6 @@ import java.util.Collections; import java.util.Date; import java.util.EnumSet; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -484,7 +483,7 @@ public class Geocache implements ICache, IWaypoint { } public List getPossibleLogTypes() { - final List logTypes = new LinkedList(); + final List logTypes = new ArrayList(); if (isEventCache()) { logTypes.add(LogType.WILL_ATTEND); logTypes.add(LogType.NOTE); @@ -511,7 +510,6 @@ public class Geocache implements ICache, IWaypoint { logTypes.add(LogType.TEMP_DISABLE_LISTING); logTypes.add(LogType.ENABLE_LISTING); logTypes.add(LogType.ARCHIVE); - logTypes.remove(LogType.UPDATE_COORDINATES); } return logTypes; } diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 864ebf8..198186c 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -110,7 +110,6 @@ public class VisitCacheActivity extends AbstractLoggingActivity implements DateD viewstates = Login.getViewstates(page); trackables = GCParser.parseTrackableLog(page); possibleLogTypes = GCParser.parseTypes(page); - possibleLogTypes.remove(LogType.UPDATE_COORDINATES); if (possibleLogTypes.isEmpty()) { showErrorLoadingData(); diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 4273da5..c637579 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -1586,15 +1586,8 @@ public abstract class GCParser { final List types = new ArrayList(); final MatcherWrapper typeBoxMatcher = new MatcherWrapper(GCConstants.PATTERN_TYPEBOX, page); - String typesText = null; - if (typeBoxMatcher.find()) { - if (typeBoxMatcher.groupCount() > 0) { - typesText = typeBoxMatcher.group(1); - } - } - - if (typesText != null) { - + if (typeBoxMatcher.find() && typeBoxMatcher.groupCount() > 0) { + String typesText = typeBoxMatcher.group(1); final MatcherWrapper typeMatcher = new MatcherWrapper(GCConstants.PATTERN_TYPE2, typesText); while (typeMatcher.find()) { if (typeMatcher.groupCount() > 1) { @@ -1610,6 +1603,9 @@ public abstract class GCParser { } } + // we don't support this log type + types.remove(LogType.UPDATE_COORDINATES); + return types; } -- cgit v1.1