From fc124633817d4d15cd6bf58487f19a1d73e64459 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 16 Dec 2013 12:48:31 +0100 Subject: integrate extremcaching.com * cherry-pick existing commits and have some basic tests * disable EC connector by default * fix faked geocodes during GPX import * parse wrongly encoded container size --- .../cgeo/geocaching/enumerations/CacheSize.java | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'main/src/cgeo/geocaching/enumerations/CacheSize.java') diff --git a/main/src/cgeo/geocaching/enumerations/CacheSize.java b/main/src/cgeo/geocaching/enumerations/CacheSize.java index a6f8df3..ee42c66 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheSize.java +++ b/main/src/cgeo/geocaching/enumerations/CacheSize.java @@ -1,7 +1,7 @@ package cgeo.geocaching.enumerations; -import cgeo.geocaching.R; import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.R; import java.util.Collections; import java.util.HashMap; @@ -56,6 +56,28 @@ public enum CacheSize { if (resultNormalized != null) { return resultNormalized; } + return getByNumber(id); + } + + /** + * Bad GPX files can contain the container size encoded as number. + * + * @param id + * @return + */ + private static CacheSize getByNumber(final String id) { + try { + int numerical = Integer.parseInt(id); + if (numerical != 0) { + for (CacheSize size : CacheSize.values()) { + if (size.comparable == numerical) { + return size; + } + } + } + } catch (NumberFormatException e) { + // ignore, as this might be a number or not + } return UNKNOWN; } -- cgit v1.1