diff options
Diffstat (limited to 'main/src/cgeo/geocaching/enumerations')
7 files changed, 33 insertions, 43 deletions
diff --git a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java index 472bad5..0703c3c 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheAttribute.java +++ b/main/src/cgeo/geocaching/enumerations/CacheAttribute.java @@ -164,15 +164,11 @@ public enum CacheAttribute { } private final static Map<String, CacheAttribute> FIND_BY_GCRAWNAME; - private final static SparseArray<CacheAttribute> FIND_BY_GCID = new SparseArray<CacheAttribute>(); private final static SparseArray<CacheAttribute> FIND_BY_OCACODE = new SparseArray<CacheAttribute>(); static { final HashMap<String, CacheAttribute> mapGcRawNames = new HashMap<String, CacheAttribute>(); for (CacheAttribute attr : values()) { mapGcRawNames.put(attr.rawName, attr); - if (attr.gcid != NO_ID) { - FIND_BY_GCID.put(attr.gcid, attr); - } if (attr.ocacode != NO_ID) { FIND_BY_OCACODE.put(attr.ocacode, attr); } @@ -184,10 +180,6 @@ public enum CacheAttribute { return rawName != null ? FIND_BY_GCRAWNAME.get(rawName) : null; } - public static CacheAttribute getByGcId(final int gcid) { - return FIND_BY_GCID.get(gcid); - } - public static CacheAttribute getByOcACode(final int ocAcode) { return FIND_BY_OCACODE.get(ocAcode); } diff --git a/main/src/cgeo/geocaching/enumerations/CacheListType.java b/main/src/cgeo/geocaching/enumerations/CacheListType.java index f482d5b..7efd705 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheListType.java +++ b/main/src/cgeo/geocaching/enumerations/CacheListType.java @@ -17,7 +17,7 @@ public enum CacheListType { */ public final boolean canSwitch; - private CacheListType(final boolean canSwitch) { + CacheListType(final boolean canSwitch) { this.canSwitch = canSwitch; } } diff --git a/main/src/cgeo/geocaching/enumerations/CacheSize.java b/main/src/cgeo/geocaching/enumerations/CacheSize.java index ee42c66..1255455 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheSize.java +++ b/main/src/cgeo/geocaching/enumerations/CacheSize.java @@ -12,30 +12,38 @@ import java.util.Map; * Enum listing cache sizes */ public enum CacheSize { - MICRO("Micro", 1, R.string.cache_size_micro), - SMALL("Small", 2, R.string.cache_size_small), - REGULAR("Regular", 3, R.string.cache_size_regular), - LARGE("Large", 4, R.string.cache_size_large), - VIRTUAL("Virtual", 0, R.string.cache_size_virtual), - NOT_CHOSEN("Not chosen", 0, R.string.cache_size_notchosen), - OTHER("Other", 0, R.string.cache_size_other), - UNKNOWN("Unknown", 0, R.string.cache_size_unknown); // CacheSize not init. yet + NANO("Nano", 0, R.string.cache_size_nano, "nano"), // used by OC only + MICRO("Micro", 1, R.string.cache_size_micro, "micro"), + SMALL("Small", 2, R.string.cache_size_small, "small"), + REGULAR("Regular", 3, R.string.cache_size_regular, "regular"), + LARGE("Large", 4, R.string.cache_size_large, "large"), + VERY_LARGE("Very large", 5, R.string.cache_size_very_large, "xlarge"), // used by OC only + NOT_CHOSEN("Not chosen", 6, R.string.cache_size_notchosen, ""), + VIRTUAL("Virtual", 7, R.string.cache_size_virtual, "none"), + OTHER("Other", 8, R.string.cache_size_other, "other"), + UNKNOWN("Unknown", -1, R.string.cache_size_unknown, ""); // CacheSize not init. yet public final String id; public final int comparable; private final int stringId; + /** + * lookup for OC JSON requests (the numeric size is deprecated for OC) + */ + private final String ocSize2; - CacheSize(String id, int comparable, int stringId) { + CacheSize(final String id, final int comparable, final int stringId, final String ocSize2) { this.id = id; this.comparable = comparable; this.stringId = stringId; + this.ocSize2 = ocSize2; } final private static Map<String, CacheSize> FIND_BY_ID; static { final HashMap<String, CacheSize> mapping = new HashMap<String, CacheSize>(); - for (CacheSize cs : values()) { + for (final CacheSize cs : values()) { mapping.put(cs.id.toLowerCase(Locale.US), cs); + mapping.put(cs.ocSize2.toLowerCase(Locale.US), cs); } // add medium as additional string for Regular mapping.put("medium", CacheSize.REGULAR); @@ -61,21 +69,21 @@ public enum CacheSize { /** * 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); + final int numerical = Integer.parseInt(id); if (numerical != 0) { - for (CacheSize size : CacheSize.values()) { + for (final CacheSize size : CacheSize.values()) { if (size.comparable == numerical) { return size; } } } - } catch (NumberFormatException e) { + } catch (final NumberFormatException e) { // ignore, as this might be a number or not } return UNKNOWN; @@ -85,4 +93,3 @@ public enum CacheSize { return CgeoApplication.getInstance().getBaseContext().getResources().getString(stringId); } } - diff --git a/main/src/cgeo/geocaching/enumerations/CacheType.java b/main/src/cgeo/geocaching/enumerations/CacheType.java index c952ba0..35fe7a1 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheType.java +++ b/main/src/cgeo/geocaching/enumerations/CacheType.java @@ -1,8 +1,8 @@ package cgeo.geocaching.enumerations; +import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.ICache; import cgeo.geocaching.R; -import cgeo.geocaching.CgeoApplication; import java.util.Collections; import java.util.HashMap; diff --git a/main/src/cgeo/geocaching/enumerations/LiveMapStrategy.java b/main/src/cgeo/geocaching/enumerations/LiveMapStrategy.java index 710c3ba..5bcaf4a 100644 --- a/main/src/cgeo/geocaching/enumerations/LiveMapStrategy.java +++ b/main/src/cgeo/geocaching/enumerations/LiveMapStrategy.java @@ -1,7 +1,7 @@ package cgeo.geocaching.enumerations; -import cgeo.geocaching.R; import cgeo.geocaching.CgeoApplication; +import cgeo.geocaching.R; import java.util.EnumSet; diff --git a/main/src/cgeo/geocaching/enumerations/LogTypeTrackable.java b/main/src/cgeo/geocaching/enumerations/LogTypeTrackable.java index 68a17a5..e008294 100644 --- a/main/src/cgeo/geocaching/enumerations/LogTypeTrackable.java +++ b/main/src/cgeo/geocaching/enumerations/LogTypeTrackable.java @@ -1,29 +1,22 @@ package cgeo.geocaching.enumerations; +import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; public enum LogTypeTrackable { - DO_NOTHING(0, "", R.string.log_tb_nothing), - VISITED(1, "_Visited", R.string.log_tb_visit), - DROPPED_OFF(2, "_DroppedOff", R.string.log_tb_drop); + DO_NOTHING("", R.string.log_tb_nothing), + VISITED("_Visited", R.string.log_tb_visit), + DROPPED_OFF("_DroppedOff", R.string.log_tb_drop); - final public int id; final public String action; - final public int resourceId; + final private int resourceId; - LogTypeTrackable(int id, String action, int resourceId) { - this.id = id; + LogTypeTrackable(String action, int resourceId) { this.action = action; this.resourceId = resourceId; } - public static LogTypeTrackable findById(int id) { - for (LogTypeTrackable logType : values()) { - if (logType.id == id) { - return logType; - } - } - return DO_NOTHING; + public String getLabel() { + return CgeoApplication.getInstance().getString(resourceId); } - } diff --git a/main/src/cgeo/geocaching/enumerations/StatusCode.java b/main/src/cgeo/geocaching/enumerations/StatusCode.java index e1a1aaa..8bda371 100644 --- a/main/src/cgeo/geocaching/enumerations/StatusCode.java +++ b/main/src/cgeo/geocaching/enumerations/StatusCode.java @@ -6,7 +6,6 @@ import android.content.res.Resources; public enum StatusCode { - COMMUNICATION_NOT_STARTED(R.string.err_start), NO_ERROR(R.string.err_none), LOG_SAVED(R.string.info_log_saved), LOGIN_PARSE_ERROR(R.string.err_parse), @@ -24,7 +23,6 @@ public enum StatusCode { LOG_POST_ERROR(R.string.err_log_post_failed), LOG_POST_ERROR_EC(R.string.err_log_post_failed_ec), NO_LOG_TEXT(R.string.warn_log_text_fill), - NO_DATA_FROM_SERVER(R.string.err_log_failed_server), NOT_LOGGED_IN(R.string.init_login_popup_failed), LOGIMAGE_POST_ERROR(R.string.err_logimage_post_failed); |
