blob: ba929b8df19fdccb0d1c173a2a822781199d9d36 (
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
|
package cgeo.geocaching.sorting;
import cgeo.geocaching.Geocache;
import cgeo.geocaching.cgData;
import cgeo.geocaching.enumerations.LogType;
public class FindsComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(Geocache cache1, Geocache cache2) {
return cache1.getLogCounts() != null && cache2.getLogCounts() != null;
}
@Override
protected int compareCaches(Geocache cache1, Geocache cache2) {
int finds1 = getFindsCount(cache1);
int finds2 = getFindsCount(cache2);
return finds2 - finds1;
}
private static int getFindsCount(Geocache cache) {
if (cache.getLogCounts().isEmpty()) {
cache.setLogCounts(cgData.loadLogCounts(cache.getGeocode()));
}
Integer logged = cache.getLogCounts().get(LogType.FOUND_IT);
if (logged != null) {
return logged;
}
return 0;
}
}
|