blob: 72cf6c83e9e777c6c57ae94018b7205d8b4cab94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package cgeo.geocaching.sorting;
import cgeo.geocaching.Geocache;
/**
* sorts caches by gcvote.com rating
*
*/
public class RatingComparator extends AbstractCacheComparator {
@Override
protected boolean canCompare(final Geocache cache1, final Geocache cache2) {
return true;
}
@Override
protected int compareCaches(final Geocache cache1, final Geocache cache2) {
final float rating1 = cache1.getRating();
final float rating2 = cache2.getRating();
// Voting can be disabled for caches, then assume an average rating instead
return Float.compare(rating2 != 0.0 ? rating2 : 2.5f, rating1 != 0.0 ? rating1 : 2.5f);
}
}
|