1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
package cgeo.geocaching.enumerations;
import cgeo.geocaching.cgeoapplication;
import android.content.res.Resources;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public enum CacheAttribute {
UNKNOWN(0, ""),
DOGS(1, "dogs"),
FEE(2, "fee"),
RAPPELLING(3, "rappelling"),
BOAT(4, "boat"),
SCUBA(5, "scuba"),
KIDS(6, "kids"),
ONEHOUR(7, "onehour"),
SCENIC(8, "scenic"),
HIKING(9, "hiking"),
CLIMBING(10, "climbing"),
WADING(11, "wading"),
SWIMMING(12, "swimming"),
AVAILABLE(13, "available"),
NIGHT(14, "night"),
WINTER(15, "winter"),
POISONOAK(17, "poisonoak"),
DANGEROUSANIMALS(18, "dangerousanimals"),
TICKS(19, "ticks"),
MINE(29, "mine"),
CLIFF(21, "cliff"),
HUNTING(22, "hunting"),
DANGER(23, "danger"),
WHEELCHAIR(24, "wheelchair"),
PARKING(25, "parking"),
PUBLIC(26, "public"),
WATER(27, "water"),
RESTROOMS(28, "restrooms"),
PHONE(29, "phone"),
PICNIC(30, "picnic"),
CAMPING(31, "camping"),
BICYCLES(32, "bicycles"),
MOTORCYCLES(33, "motorcycles"),
QUADS(34, "quads"),
JEEPS(35, "jeeps"),
SNOWMOBILES(36, "snowmobiles"),
HORSES(37, "horses"),
CAMPFIRES(38, "campfires"),
THORN(39, "thorn"),
STEALTH(40, "stealth"),
STROLLER(41, "stroller"),
FIRSTAID(42, "firstaid"),
COW(43, "cow"),
FLASHLIGHT(44, "flashlight"),
LANDF(45, "landf"),
RV(46, "rv"),
FIELD_PUZZLE(47, "field_puzzle"),
UV(48, "uv"),
SNOWSHOES(49, "snowshoes"),
SKIIS(50, "skiis"),
SPECIAL_TOOLS(51, "s_tool"),
NIGHTCACHE(52, "nightcache"),
PARKNGRAB(53, "parkngrab"),
ABANDONED_BUILDING(54, "abandonedbuilding"),
HIKE_SHORT(55, "hike_short"),
HIKE_MED(56, "hike_med"),
HIKE_LONG(57, "hike_long"),
FUEL(58, "fuel"),
FOOD(59, "food"),
WIRELESS_BEACON(60, "wirelessbeacon"),
PARTNERSHIP(61, "partnership"),
SEASONAL(62, "seasonal"),
TOURIST_OK(63, "touristok"),
TREECLIMBING(64, "treeclimbing"),
FRONTYARD(65, "frontyard"),
TEAMWORK(66, "teamwork");
public static final String INTERNAL_PRE = "attribute_";
public static final String INTERNAL_YES = "_yes";
public static final String INTERNAL_NO = "_no";
private static final Resources res = cgeoapplication.getInstance().getResources();
private static final String packageName = cgeoapplication.getInstance().getBaseContext().getPackageName();
public final int id;
public final String gcRawName;
private CacheAttribute(final int id, final String gcRawName) {
this.id = id;
this.gcRawName = gcRawName;
}
public String getL10n(final boolean enabled) {
final String attributeDescriptor = INTERNAL_PRE + gcRawName + (enabled ? INTERNAL_YES : INTERNAL_NO);
int id = res.getIdentifier(attributeDescriptor, "string", packageName);
return (id > 0) ? res.getString(id) : attributeDescriptor;
}
private final static Map<String, CacheAttribute> FIND_BY_GCRAWNAME;
static {
final HashMap<String, CacheAttribute> mapGcRawNames = new HashMap<String, CacheAttribute>();
for (CacheAttribute attr : values()) {
mapGcRawNames.put(attr.gcRawName, attr);
}
FIND_BY_GCRAWNAME = Collections.unmodifiableMap(mapGcRawNames);
}
public static CacheAttribute getById(final int id) {
for (CacheAttribute attr : values()) {
if (attr.id == id) {
return attr;
}
}
return UNKNOWN;
}
public static CacheAttribute getByGcRawName(final String gcRawName) {
final CacheAttribute result = gcRawName != null ? FIND_BY_GCRAWNAME.get(gcRawName) : null;
if (result == null) {
return UNKNOWN;
}
return result;
}
public static String trimAttributeName(String attributeName) {
if (null == attributeName) {
return "";
}
return attributeName.replace(INTERNAL_PRE, "").replace(INTERNAL_YES, "").replace(INTERNAL_NO, "").trim();
}
}
|