diff options
Diffstat (limited to 'src/cgeo/geocaching/sorting/DistanceComparator.java')
| -rw-r--r-- | src/cgeo/geocaching/sorting/DistanceComparator.java | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/cgeo/geocaching/sorting/DistanceComparator.java b/src/cgeo/geocaching/sorting/DistanceComparator.java index 9a5b551..9bc05a2 100644 --- a/src/cgeo/geocaching/sorting/DistanceComparator.java +++ b/src/cgeo/geocaching/sorting/DistanceComparator.java @@ -5,36 +5,36 @@ import cgeo.geocaching.geopoint.Geopoint; /** * sorts caches by distance to current position - * + * */ public class DistanceComparator extends AbstractCacheComparator { - private final Geopoint coords; + private final Geopoint coords; - public DistanceComparator(final Geopoint coords) { - this.coords = coords; - } + public DistanceComparator(final Geopoint coords) { + this.coords = coords; + } - @Override - protected boolean canCompare(cgCache cache1, cgCache cache2) { - return true; - } + @Override + protected boolean canCompare(cgCache cache1, cgCache cache2) { + return true; + } - @Override - protected int compareCaches(final cgCache cache1, final cgCache cache2) { - if ((cache1.coords == null || cache2.coords == null) - && cache1.distance != null && cache2.distance != null) { - return Double.compare(cache1.distance, cache2.distance); - } else { - if (cache1.coords == null) { - return 1; - } - if (cache2.coords == null) { - return -1; - } + @Override + protected int compareCaches(final cgCache cache1, final cgCache cache2) { + if ((cache1.coords == null || cache2.coords == null) + && cache1.distance != null && cache2.distance != null) { + return Double.compare(cache1.distance, cache2.distance); + } else { + if (cache1.coords == null) { + return 1; + } + if (cache2.coords == null) { + return -1; + } + + return Float.compare(coords.distanceTo(cache1.coords), + coords.distanceTo(cache2.coords)); + } + } - return Float.compare(coords.distanceTo(cache1.coords), - coords.distanceTo(cache2.coords)); - } - } - } |
