blob: b99c3c06ab1164659db15a7de36fd42db0677acf (
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
|
package cgeo.geocaching.sorting;
import cgeo.geocaching.Geocache;
/**
* sort caches by state (normal, disabled, archived)
*
*/
public class StateComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(final Geocache cache1, final Geocache cache2) {
return true;
}
@Override
protected int compareCaches(final Geocache cache1, final Geocache cache2) {
return getState(cache1) - getState(cache2);
}
private static int getState(final Geocache cache) {
if (cache.isDisabled()) {
return 1;
}
if (cache.isArchived()) {
return 2;
}
return 0;
}
}
|