From a5b5204d53489e0d257ffd5fcb1a41eae9e47835 Mon Sep 17 00:00:00 2001 From: Torsten Keil Date: Wed, 22 Feb 2012 20:34:45 +0100 Subject: Replaced parsing for find count by usage of defined pattern --- .../cgeo/geocaching/utils/LogTemplateProvider.java | 31 ++-------------------- 1 file changed, 2 insertions(+), 29 deletions(-) (limited to 'main/src/cgeo/geocaching/utils/LogTemplateProvider.java') 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(" ([,\\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(",", "")); } - } -- cgit v1.1