blob: e58eb43eb1f33981d7196240320c2fc24de5cd3e (
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
|
package cgeo.geocaching;
import java.util.Comparator;
import android.util.Log;
/**
* compares by number of items in inventory
* @author bananeweizen
*
*/
public class cgCacheInventoryComparator implements Comparator<cgCache> {
public int compare(cgCache cache1, cgCache cache2) {
try {
int itemCount1 = 0;
int itemCount2 = 0;
if (cache1.difficulty != null) {
itemCount1 = cache1.inventoryItems;
}
if (cache2.difficulty != null) {
itemCount2 = cache2.inventoryItems;
}
if (itemCount1 < itemCount2) {
return 1;
} else if (itemCount2 < itemCount1) {
return -1;
} else {
return 0;
}
} catch (Exception e) {
Log.e(cgSettings.tag, "cgCacheInventoryComparator.compare: " + e.toString());
}
return 0;
}
}
|