blob: 8b2bb00c1451c996e50067885d87bcc548b4cf24 (
plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
package cgeo.geocaching;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import android.text.Spannable;
public class cgCache {
public Long updated = null;
public Long detailedUpdate = null;
public Long visitedDate = null;
public Integer reason = 0;
public Boolean detailed = false;
public String geocode = "";
public String cacheid = "";
public String guid = "";
public String type = "";
public String name = "";
public Spannable nameSp = null;
public String owner = "";
public String ownerReal = "";
public Date hidden = null;
public String hint = "";
public String size = "";
public Float difficulty = new Float(0);
public Float terrain = new Float(0);
public Double direction = null;
public Double distance = null;
public String latlon = "";
public String latitudeString = "";
public String longitudeString = "";
public String location = "";
public Double latitude = null;
public Double longitude = null;
public boolean reliableLatLon = false;
public Double elevation = null;
public String shortdesc = "";
public String description = "";
public boolean disabled = false;
public boolean archived = false;
public boolean members = false;
public boolean found = false;
public boolean favourite = false;
public boolean own = false;
public Integer favouriteCnt = null;
public Float rating = null;
public Integer votes = null;
public Float myVote = null;
public int inventoryItems = 0;
public boolean onWatchlist = false;
public ArrayList<String> attributes = null;
public ArrayList<cgWaypoint> waypoints = null;
public ArrayList<cgSpoiler> spoilers = null;
public ArrayList<cgLog> logs = null;
public ArrayList<cgTrackable> inventory = null;
public HashMap<Integer, Integer> logCounts = new HashMap<Integer, Integer>();
public boolean logOffline = false;
// temporary values
public boolean statusChecked = false;
public boolean statusCheckedView = false;
public String directionImg = null;
public cgCache merge(cgData storage) {
boolean loadA = true;
boolean loadW = true;
boolean loadS = true;
boolean loadL = true;
boolean loadI = true;
if (attributes == null || attributes.isEmpty() == true) {
loadA = false;
}
if (waypoints == null || waypoints.isEmpty() == true) {
loadW = false;
}
if (spoilers == null || spoilers.isEmpty() == true) {
loadS = false;
}
if (logs == null || logs.isEmpty() == true) {
loadL = false;
}
if (inventory == null || inventory.isEmpty() == true) {
loadI = false;
}
final cgCache oldCache = storage.loadCache(geocode, guid, loadA, loadW, loadS, loadL, loadI, false);
if (oldCache == null) {
return this;
}
updated = System.currentTimeMillis();
if (detailed == false && oldCache.detailed == true) {
detailed = true;
detailedUpdate = System.currentTimeMillis();
}
if (visitedDate == null || visitedDate == 0) {
visitedDate = oldCache.visitedDate;
}
if (reason == null || reason == 0) {
reason = oldCache.reason;
}
if (geocode == null || geocode.length() == 0) {
geocode = oldCache.geocode;
}
if (cacheid == null || cacheid.length() == 0) {
cacheid = oldCache.cacheid;
}
if (guid == null || guid.length() == 0) {
guid = oldCache.guid;
}
if (type == null || type.length() == 0) {
type = oldCache.type;
}
if (name == null || name.length() == 0) {
name = oldCache.name;
}
if (nameSp == null || nameSp.length() == 0) {
nameSp = oldCache.nameSp;
}
if (owner == null || owner.length() == 0) {
owner = oldCache.owner;
}
if (ownerReal == null || ownerReal.length() == 0) {
ownerReal = oldCache.ownerReal;
}
if (hidden == null) {
hidden = oldCache.hidden;
}
if (hint == null || hint.length() == 0) {
hint = oldCache.hint;
}
if (size == null || size.length() == 0) {
size = oldCache.size;
}
if (difficulty == null || difficulty == 0) {
difficulty = oldCache.difficulty;
}
if (terrain == null || terrain == 0) {
terrain = oldCache.terrain;
}
if (direction == null) {
direction = oldCache.direction;
}
if (distance == null) {
distance = oldCache.distance;
}
if (latlon == null || latlon.length() == 0) {
latlon = oldCache.latlon;
}
if (latitudeString == null || latitudeString.length() == 0) {
latitudeString = oldCache.latitudeString;
}
if (longitudeString == null || longitudeString.length() == 0) {
longitudeString = oldCache.longitudeString;
}
if (location == null || location.length() == 0) {
location = oldCache.location;
}
if (latitude == null) {
latitude = oldCache.latitude;
}
if (longitude == null) {
longitude = oldCache.longitude;
}
if (elevation == null) {
elevation = oldCache.elevation;
}
if (shortdesc == null || shortdesc.length() == 0) {
shortdesc = oldCache.shortdesc;
}
if (description == null || description.length() == 0) {
description = oldCache.description;
}
if (favouriteCnt == null) {
favouriteCnt = oldCache.favouriteCnt;
}
if (rating == null) {
rating = oldCache.rating;
}
if (votes == null) {
votes = oldCache.votes;
}
if (myVote == null) {
myVote = oldCache.myVote;
}
if (inventoryItems == 0) {
inventoryItems = oldCache.inventoryItems;
}
if (attributes == null) {
attributes = oldCache.attributes;
}
if (waypoints == null) {
waypoints = oldCache.waypoints;
}
if (spoilers == null) {
spoilers = oldCache.spoilers;
}
if (inventory == null) {
inventory = oldCache.inventory;
}
if (logs == null || logs.isEmpty()) { // keep last known logs if none
logs = oldCache.logs;
}
return this;
}
public boolean hasTrackables(){
return inventoryItems > 0;
}
public boolean canBeAddedToCalendar() {
// is event type?
if (!type.equalsIgnoreCase("event") && !type.equalsIgnoreCase("mega") && !type.equalsIgnoreCase("cito")) {
return false;
}
// has event date set?
if (hidden == null) {
return false;
}
// is in future?
Date today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
if (hidden.compareTo(today) <= 0) {
return false;
}
return true;
}
}
|