diff options
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 16 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 20 |
2 files changed, 18 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 4da2b8d..bac4600 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -439,22 +439,6 @@ public class Geocache implements ICache, IWaypoint { return hidden.compareTo(cal.getTime()) >= 0; } - /** - * Checks if a page contains the guid of a cache - * - * @param page - * the page to search in, may be null - * @return true if the page contains the guid of the cache, false otherwise - */ - public boolean isGuidContainedInPage(final String page) { - if (StringUtils.isBlank(page) || StringUtils.isBlank(guid)) { - return false; - } - final Boolean found = Pattern.compile(guid, Pattern.CASE_INSENSITIVE).matcher(page).find(); - Log.i("Geocache.isGuidContainedInPage: guid '" + guid + "' " + (found ? "" : "not ") + "found"); - return found; - } - public boolean isEventCache() { return cacheType.getValue().isEvent(); } diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 9d6762b..8e59e5e 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -62,6 +62,7 @@ import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.regex.Pattern; public abstract class GCParser { private final static SynchronizedDateFormat dateTbIn1 = new SynchronizedDateFormat("EEEEE, dd MMMMM yyyy", Locale.ENGLISH); // Saturday, 28 March 2009 @@ -1310,7 +1311,7 @@ public abstract class GCParser { return false; // error } - final boolean guidOnPage = cache.isGuidContainedInPage(page); + final boolean guidOnPage = isGuidContainedInPage(cache, page); if (guidOnPage) { Log.i("GCParser.addToWatchlist: cache is on watchlist"); cache.setOnWatchlist(true); @@ -1344,7 +1345,7 @@ public abstract class GCParser { GCLogin.transferViewstates(page, params); page = Network.getResponseData(Network.postRequest(uri, params)); - final boolean guidOnPage = cache.isGuidContainedInPage(page); + final boolean guidOnPage = isGuidContainedInPage(cache, page); if (!guidOnPage) { Log.i("GCParser.removeFromWatchlist: cache removed from watchlist"); cache.setOnWatchlist(false); @@ -1354,6 +1355,21 @@ public abstract class GCParser { return !guidOnPage; // on watch list (=error) / not on watch list } + /** + * Checks if a page contains the guid of a cache + * + * @param cache the geocache + * @param page + * the page to search in, may be null + * @return true if the page contains the guid of the cache, false otherwise + */ + private static boolean isGuidContainedInPage(final Geocache cache, final String page) { + if (StringUtils.isBlank(page) || StringUtils.isBlank(cache.getGuid())) { + return false; + } + return Pattern.compile(cache.getGuid(), Pattern.CASE_INSENSITIVE).matcher(page).find(); + } + @Nullable static String requestHtmlPage(@Nullable final String geocode, @Nullable final String guid, final String log, final String numlogs) { final Parameters params = new Parameters("decrypt", "y"); |
