aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/enumerations/CacheSize.java
diff options
context:
space:
mode:
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;
}