diff options
| author | Torsten Keil <github@torsten-keil.net> | 2012-02-22 20:34:45 +0100 |
|---|---|---|
| committer | Torsten Keil <github@torsten-keil.net> | 2012-02-22 20:34:45 +0100 |
| commit | a5b5204d53489e0d257ffd5fcb1a41eae9e47835 (patch) | |
| tree | 5ccca2c4ac3444f5b45002adc423c7c3d6955fff /main/src/cgeo/geocaching/utils/LogTemplateProvider.java | |
| parent | 0b0106e00af4ca9d99bf2ed00948e78fc7b36689 (diff) | |
| download | cgeo-a5b5204d53489e0d257ffd5fcb1a41eae9e47835.zip cgeo-a5b5204d53489e0d257ffd5fcb1a41eae9e47835.tar.gz cgeo-a5b5204d53489e0d257ffd5fcb1a41eae9e47835.tar.bz2 | |
Replaced parsing for find count by usage of defined pattern
Diffstat (limited to 'main/src/cgeo/geocaching/utils/LogTemplateProvider.java')
| -rw-r--r-- | main/src/cgeo/geocaching/utils/LogTemplateProvider.java | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java index 8606649..775f5cc 100644 --- a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java +++ b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java @@ -1,16 +1,12 @@ package cgeo.geocaching.utils; +import cgeo.geocaching.GCConstants; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; import org.apache.commons.lang3.StringUtils; -import android.util.Log; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * provides all the available templates for logging * @@ -131,29 +127,6 @@ public class LogTemplateProvider { return -1; } - int findCount = -1; - - try { - final Pattern findPattern = Pattern.compile("<strong><img.+?icon_smile.+?title=\"Caches Found\" /> ([,\\d]+)", Pattern.CASE_INSENSITIVE); - final Matcher findMatcher = findPattern.matcher(page); - if (findMatcher.find()) { - if (findMatcher.groupCount() > 0) { - String count = findMatcher.group(1); - - if (count != null) { - if (count.length() == 0) { - findCount = 0; - } else { - findCount = Integer.parseInt(count.replaceAll("[.,]", "")); - } - } - } - } - } catch (Exception e) { - Log.w(Settings.tag, "cgBase.parseFindCount: " + e.toString()); - } - - return findCount; + return Integer.parseInt(BaseUtils.getMatch(page, GCConstants.PATTERN_CACHES_FOUND, true, "-1").replaceAll(",", "")); } - } |
