aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/enumerations/CacheSize.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-12-16 12:48:31 +0100
committerBananeweizen <bananeweizen@gmx.de>2013-12-16 12:48:31 +0100
commitfc124633817d4d15cd6bf58487f19a1d73e64459 (patch)
treeb3208a5c12fc2136bc0f38fe8ee7bc78b141d1ca /main/src/cgeo/geocaching/enumerations/CacheSize.java
parent14874d409a6547bc36c3b3946d55a81ad61da97a (diff)
downloadcgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.zip
cgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.tar.gz
cgeo-fc124633817d4d15cd6bf58487f19a1d73e64459.tar.bz2
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
Diffstat (limited to 'main/src/cgeo/geocaching/enumerations/CacheSize.java')
-rw-r--r--main/src/cgeo/geocaching/enumerations/CacheSize.java24
1 files changed, 23 insertions, 1 deletions
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;
}