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
|
package cgeo.geocaching.enumerations;
import cgeo.geocaching.R;
import cgeo.geocaching.cgeoapplication;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Different log types
*/
public enum LogType {
FOUND_IT(2, "2", "found it", R.string.log_found),
DIDNT_FIND_IT(3, "3", "didn't find it", R.string.log_dnf),
NOTE(4, "4", "write note", R.string.log_note),
PUBLISH_LISTING(1003, "24", "publish listing", R.string.log_published),
ENABLE_LISTING(23, "23", "enable listing", R.string.log_enabled),
ARCHIVE(5, "5", "archive", R.string.log_archived),
UNARCHIVE(12, "12", "unarchive", R.string.log_unarchived),
TEMP_DISABLE_LISTING(22, "22", "temporarily disable listing", R.string.log_disabled),
NEEDS_ARCHIVE(7, "7", "needs archived", R.string.log_needs_archived),
WILL_ATTEND(9, "9", "will attend", R.string.log_attend),
ATTENDED(10, "10", "attended", R.string.log_attended),
RETRIEVED_IT(13, "13", "retrieved it", R.string.log_retrieved),
PLACED_IT(14, "14", "placed it", R.string.log_placed),
GRABBED_IT(19, "19", "grabbed it", R.string.log_grabbed),
NEEDS_MAINTENANCE(45, "45", "needs maintenance", R.string.log_maintenance_needed),
OWNER_MAINTENANCE(46, "46", "owner maintenance", R.string.log_maintained),
UPDATE_COORDINATES(47, "47", "update coordinates", R.string.log_update),
DISCOVERED_IT(48, "48", "discovered it", R.string.log_discovered),
POST_REVIEWER_NOTE(18, "68", "post reviewer note", R.string.log_reviewer),
VISIT(1001, "75", "visit", R.string.log_tb_visit),
WEBCAM_PHOTO_TAKEN(11, "11", "webcam photo taken", R.string.log_webcam),
ANNOUNCEMENT(74, "74", "announcement", R.string.log_announcement),
MOVE_COLLECTION(69, "69", "unused_collection", R.string.log_movecollection),
MOVE_INVENTORY(70, "70", "unused_inventory", R.string.log_moveinventory),
RETRACT(25, "25", "rectract listing", R.string.log_retractlisting),
UNKNOWN(0, "unknown", "", R.string.err_unknown); // LogType not init. yet
public final int id;
public final String iconName;
public final String type;
private final int stringId;
private LogType(int id, String iconName, String type, int stringId) {
this.id = id;
this.iconName = iconName;
this.type = type;
this.stringId = stringId;
}
private final static Map<String, LogType> FIND_BY_ICONNAME;
private final static Map<String, LogType> FIND_BY_TYPE;
static {
final HashMap<String, LogType> mappingPattern = new HashMap<String, LogType>();
final HashMap<String, LogType> mappingType = new HashMap<String, LogType>();
for (LogType lt : values()) {
mappingPattern.put(lt.iconName, lt);
mappingType.put(lt.type, lt);
}
FIND_BY_ICONNAME = Collections.unmodifiableMap(mappingPattern);
FIND_BY_TYPE = Collections.unmodifiableMap(mappingType);
}
public static LogType getById(final int id) {
for (LogType logType : values()) {
if (logType.id == id) {
return logType;
}
}
return UNKNOWN;
}
public static LogType getByIconName(final String imageType) {
final LogType result = imageType != null ? LogType.FIND_BY_ICONNAME.get(imageType.toLowerCase().trim()) : null;
if (result == null) {
return UNKNOWN;
}
return result;
}
public static LogType getByType(final String type) {
final LogType result = type != null ? LogType.FIND_BY_TYPE.get(type.toLowerCase().trim()) : null;
if (result == null) {
return UNKNOWN;
}
return result;
}
public final String getL10n() {
return cgeoapplication.getInstance().getBaseContext().getResources().getString(stringId);
}
}
|