aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/sorting
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/sorting')
-rw-r--r--src/cgeo/geocaching/sorting/AbstractCacheComparator.java62
-rw-r--r--src/cgeo/geocaching/sorting/DateComparator.java45
-rw-r--r--src/cgeo/geocaching/sorting/DifficultyComparator.java28
-rw-r--r--src/cgeo/geocaching/sorting/DistanceComparator.java52
-rw-r--r--src/cgeo/geocaching/sorting/FindsComparator.java62
-rw-r--r--src/cgeo/geocaching/sorting/GeocodeComparator.java34
-rw-r--r--src/cgeo/geocaching/sorting/InventoryComparator.java33
-rw-r--r--src/cgeo/geocaching/sorting/NameComparator.java22
-rw-r--r--src/cgeo/geocaching/sorting/PopularityComparator.java28
-rw-r--r--src/cgeo/geocaching/sorting/RatingComparator.java46
-rw-r--r--src/cgeo/geocaching/sorting/SizeComparator.java77
-rw-r--r--src/cgeo/geocaching/sorting/StateComparator.java38
-rw-r--r--src/cgeo/geocaching/sorting/TerrainComparator.java28
-rw-r--r--src/cgeo/geocaching/sorting/VisitComparator.java30
-rw-r--r--src/cgeo/geocaching/sorting/VoteComparator.java50
15 files changed, 321 insertions, 314 deletions
diff --git a/src/cgeo/geocaching/sorting/AbstractCacheComparator.java b/src/cgeo/geocaching/sorting/AbstractCacheComparator.java
index 4630888..a7a3336 100644
--- a/src/cgeo/geocaching/sorting/AbstractCacheComparator.java
+++ b/src/cgeo/geocaching/sorting/AbstractCacheComparator.java
@@ -1,42 +1,46 @@
package cgeo.geocaching.sorting;
-import android.util.Log;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgSettings;
+import android.util.Log;
+
/**
* abstract super implementation for all cache comparators
- *
+ *
*/
public abstract class AbstractCacheComparator implements CacheComparator {
- @Override
- public final int compare(cgCache cache1, cgCache cache2) {
- try {
- // first check that we have all necessary data for the comparison
- if (!canCompare(cache1, cache2)) {
- return 0;
- }
- return compareCaches(cache1, cache2);
- } catch (Exception e) {
- Log.e(cgSettings.tag, "AbstractCacheComparator.compare: " + e.toString());
- }
- return 0;
- }
+ @Override
+ public final int compare(cgCache cache1, cgCache cache2) {
+ try {
+ // first check that we have all necessary data for the comparison
+ if (!canCompare(cache1, cache2)) {
+ return 0;
+ }
+ return compareCaches(cache1, cache2);
+ } catch (Exception e) {
+ Log.e(cgSettings.tag, "AbstractCacheComparator.compare: " + e.toString());
+ }
+ return 0;
+ }
- /**
- * check necessary preconditions (like missing fields) before running the comparison itself
- * @param cache1
- * @param cache2
- * @return
- */
- protected abstract boolean canCompare(final cgCache cache1, final cgCache cache2);
+ /**
+ * check necessary preconditions (like missing fields) before running the comparison itself
+ *
+ * @param cache1
+ * @param cache2
+ * @return
+ */
+ protected abstract boolean canCompare(final cgCache cache1, final cgCache cache2);
- /**
- * compares two caches. Logging and exception handling is implemented outside this method already.
- * @param cache1
- * @param cache2
- * @return an integer < 0 if cache1 is less than cache2, 0 if they are equal, and > 0 if cache1 is greater than cache2.
- */
- protected abstract int compareCaches(final cgCache cache1, final cgCache cache2);
+ /**
+ * compares two caches. Logging and exception handling is implemented outside this method already.
+ *
+ * @param cache1
+ * @param cache2
+ * @return an integer < 0 if cache1 is less than cache2, 0 if they are equal, and > 0 if cache1 is greater than
+ * cache2.
+ */
+ protected abstract int compareCaches(final cgCache cache1, final cgCache cache2);
}
diff --git a/src/cgeo/geocaching/sorting/DateComparator.java b/src/cgeo/geocaching/sorting/DateComparator.java
index f1d08a4..acc4ff2 100644
--- a/src/cgeo/geocaching/sorting/DateComparator.java
+++ b/src/cgeo/geocaching/sorting/DateComparator.java
@@ -1,34 +1,35 @@
package cgeo.geocaching.sorting;
-import java.util.Date;
-
import cgeo.geocaching.cgCache;
+import java.util.Date;
+
/**
* compares caches by date
+ *
* @author bananeweizen
- *
+ *
*/
public class DateComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return true;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return true;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- Date date1 = cache1.hidden;
- Date date2 = cache2.hidden;
- if (date1 != null && date2 != null) {
- return date1.compareTo(date2);
- }
- if (date1 != null) {
- return -1;
- }
- if (date2 != null) {
- return 1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ Date date1 = cache1.hidden;
+ Date date2 = cache2.hidden;
+ if (date1 != null && date2 != null) {
+ return date1.compareTo(date2);
+ }
+ if (date1 != null) {
+ return -1;
+ }
+ if (date2 != null) {
+ return 1;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/DifficultyComparator.java b/src/cgeo/geocaching/sorting/DifficultyComparator.java
index cb16b7c..ad55691 100644
--- a/src/cgeo/geocaching/sorting/DifficultyComparator.java
+++ b/src/cgeo/geocaching/sorting/DifficultyComparator.java
@@ -4,22 +4,22 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by difficulty
- *
+ *
*/
public class DifficultyComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.difficulty != null && cache2.difficulty != null;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.difficulty != null && cache2.difficulty != null;
+ }
- @Override
- protected int compareCaches(final cgCache cache1, final cgCache cache2) {
- if (cache1.difficulty > cache2.difficulty) {
- return 1;
- } else if (cache2.difficulty > cache1.difficulty) {
- return -1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(final cgCache cache1, final cgCache cache2) {
+ if (cache1.difficulty > cache2.difficulty) {
+ return 1;
+ } else if (cache2.difficulty > cache1.difficulty) {
+ return -1;
+ }
+ return 0;
+ }
} \ No newline at end of file
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));
- }
- }
-
}
diff --git a/src/cgeo/geocaching/sorting/FindsComparator.java b/src/cgeo/geocaching/sorting/FindsComparator.java
index 8553f4b..efde22d 100644
--- a/src/cgeo/geocaching/sorting/FindsComparator.java
+++ b/src/cgeo/geocaching/sorting/FindsComparator.java
@@ -5,36 +5,36 @@ import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeoapplication;
public class FindsComparator extends AbstractCacheComparator implements
- CacheComparator {
-
- private cgeoapplication app;
-
- public FindsComparator(cgeoapplication app) {
- this.app = app;
- }
-
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.logCounts != null && cache2.logCounts != null;
- }
-
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- int finds1 = getFindsCount(cache1);
- int finds2 = getFindsCount(cache2);
- return finds2 - finds1;
- }
-
- private int getFindsCount(cgCache cache) {
- int finds = 0;
- if (cache.logCounts.isEmpty()) {
- cache.logCounts = app.loadLogCounts(cache.geocode);
- }
- Integer logged = cache.logCounts.get(cgBase.LOG_FOUND_IT);
- if (logged != null) {
- finds = logged;
- }
- return finds;
- }
+ CacheComparator {
+
+ private cgeoapplication app;
+
+ public FindsComparator(cgeoapplication app) {
+ this.app = app;
+ }
+
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.logCounts != null && cache2.logCounts != null;
+ }
+
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ int finds1 = getFindsCount(cache1);
+ int finds2 = getFindsCount(cache2);
+ return finds2 - finds1;
+ }
+
+ private int getFindsCount(cgCache cache) {
+ int finds = 0;
+ if (cache.logCounts.isEmpty()) {
+ cache.logCounts = app.loadLogCounts(cache.geocode);
+ }
+ Integer logged = cache.logCounts.get(cgBase.LOG_FOUND_IT);
+ if (logged != null) {
+ finds = logged;
+ }
+ return finds;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/GeocodeComparator.java b/src/cgeo/geocaching/sorting/GeocodeComparator.java
index 957545b..004970b 100644
--- a/src/cgeo/geocaching/sorting/GeocodeComparator.java
+++ b/src/cgeo/geocaching/sorting/GeocodeComparator.java
@@ -1,28 +1,28 @@
package cgeo.geocaching.sorting;
-import org.apache.commons.lang3.StringUtils;
-
import cgeo.geocaching.cgCache;
+import org.apache.commons.lang3.StringUtils;
+
/**
* sorts caches by GC code, therefore effectively sorting by cache age
- *
+ *
*/
public class GeocodeComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return StringUtils.isNotBlank(cache1.geocode)
- && StringUtils.isNotBlank(cache2.geocode);
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return StringUtils.isNotBlank(cache1.geocode)
+ && StringUtils.isNotBlank(cache2.geocode);
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- if (cache1.geocode.length() > cache2.geocode.length()) {
- return 1;
- } else if (cache2.geocode.length() > cache1.geocode.length()) {
- return -1;
- }
- return cache1.geocode.compareToIgnoreCase(cache2.geocode);
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ if (cache1.geocode.length() > cache2.geocode.length()) {
+ return 1;
+ } else if (cache2.geocode.length() > cache1.geocode.length()) {
+ return -1;
+ }
+ return cache1.geocode.compareToIgnoreCase(cache2.geocode);
+ }
}
diff --git a/src/cgeo/geocaching/sorting/InventoryComparator.java b/src/cgeo/geocaching/sorting/InventoryComparator.java
index c126e41..ed4dcb7 100644
--- a/src/cgeo/geocaching/sorting/InventoryComparator.java
+++ b/src/cgeo/geocaching/sorting/InventoryComparator.java
@@ -4,25 +4,26 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by number of items in inventory
+ *
* @author bananeweizen
- *
+ *
*/
public class InventoryComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return true;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return true;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- int itemCount1 = cache1.inventoryItems;
- int itemCount2 = cache2.inventoryItems;
- if (itemCount1 < itemCount2) {
- return 1;
- } else if (itemCount2 < itemCount1) {
- return -1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ int itemCount1 = cache1.inventoryItems;
+ int itemCount2 = cache2.inventoryItems;
+ if (itemCount1 < itemCount2) {
+ return 1;
+ } else if (itemCount2 < itemCount1) {
+ return -1;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/NameComparator.java b/src/cgeo/geocaching/sorting/NameComparator.java
index 9f72258..43707f6 100644
--- a/src/cgeo/geocaching/sorting/NameComparator.java
+++ b/src/cgeo/geocaching/sorting/NameComparator.java
@@ -1,22 +1,22 @@
package cgeo.geocaching.sorting;
-import org.apache.commons.lang3.StringUtils;
-
import cgeo.geocaching.cgCache;
+import org.apache.commons.lang3.StringUtils;
+
/**
* sorts caches by name
- *
+ *
*/
public class NameComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return StringUtils.isNotBlank(cache1.name) && StringUtils.isNotBlank(cache2.name);
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return StringUtils.isNotBlank(cache1.name) && StringUtils.isNotBlank(cache2.name);
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- return cache1.name.compareToIgnoreCase(cache2.name);
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ return cache1.name.compareToIgnoreCase(cache2.name);
+ }
}
diff --git a/src/cgeo/geocaching/sorting/PopularityComparator.java b/src/cgeo/geocaching/sorting/PopularityComparator.java
index cc1a6ea..eb02f44 100644
--- a/src/cgeo/geocaching/sorting/PopularityComparator.java
+++ b/src/cgeo/geocaching/sorting/PopularityComparator.java
@@ -4,22 +4,22 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by popularity (favorite count)
- *
+ *
*/
public class PopularityComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.favouriteCnt != null && cache2.favouriteCnt != null;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.favouriteCnt != null && cache2.favouriteCnt != null;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- if (cache1.favouriteCnt < cache2.favouriteCnt) {
- return 1;
- } else if (cache2.favouriteCnt < cache1.favouriteCnt) {
- return -1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ if (cache1.favouriteCnt < cache2.favouriteCnt) {
+ return 1;
+ } else if (cache2.favouriteCnt < cache1.favouriteCnt) {
+ return -1;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/RatingComparator.java b/src/cgeo/geocaching/sorting/RatingComparator.java
index 3cdf474..4542ed5 100644
--- a/src/cgeo/geocaching/sorting/RatingComparator.java
+++ b/src/cgeo/geocaching/sorting/RatingComparator.java
@@ -4,33 +4,33 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by gcvote.com rating
- *
+ *
*/
public class RatingComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.rating != null && cache2.rating != null;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.rating != null && cache2.rating != null;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- Float rating1 = cache1.rating;
- Float rating2 = cache2.rating;
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ Float rating1 = cache1.rating;
+ Float rating2 = cache2.rating;
- // voting can be disabled for caches, then assume an average rating instead
- if (rating1 == 0.0) {
- rating1 = 2.5f;
- }
- if (rating2 == 0.0) {
- rating2 = 2.5f;
- }
+ // voting can be disabled for caches, then assume an average rating instead
+ if (rating1 == 0.0) {
+ rating1 = 2.5f;
+ }
+ if (rating2 == 0.0) {
+ rating2 = 2.5f;
+ }
- if (rating1 < rating2) {
- return 1;
- } else if (rating2 < rating1) {
- return -1;
- }
- return 0;
- }
+ if (rating1 < rating2) {
+ return 1;
+ } else if (rating2 < rating1) {
+ return -1;
+ }
+ return 0;
+ }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/sorting/SizeComparator.java b/src/cgeo/geocaching/sorting/SizeComparator.java
index cff5c49..56ca593 100644
--- a/src/cgeo/geocaching/sorting/SizeComparator.java
+++ b/src/cgeo/geocaching/sorting/SizeComparator.java
@@ -1,50 +1,51 @@
package cgeo.geocaching.sorting;
-import org.apache.commons.lang3.StringUtils;
-
import cgeo.geocaching.cgCache;
+import org.apache.commons.lang3.StringUtils;
+
/**
* sorts caches by size
- *
+ *
*/
public class SizeComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return StringUtils.isNotBlank(cache1.size) && StringUtils.isNotBlank(cache2.size);
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return StringUtils.isNotBlank(cache1.size) && StringUtils.isNotBlank(cache2.size);
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- int size1 = getSize(cache1);
- int size2 = getSize(cache2);
- if (size1 < size2) {
- return 1;
- } else if (size2 < size1) {
- return -1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ int size1 = getSize(cache1);
+ int size2 = getSize(cache2);
+ if (size1 < size2) {
+ return 1;
+ } else if (size2 < size1) {
+ return -1;
+ }
+ return 0;
+ }
- /**
- * speed optimized comparison of size string
- * @param cache
- * @return
- */
- private static int getSize(final cgCache cache) {
- char c = cache.size.charAt(0);
- switch (c) {
- case 'm': // micro
- return 1;
- case 's': // small
- return 2;
- case 'r': // regular
- return 3;
- case 'l': // large
- return 4;
- default:
- return 0;
- }
- }
+ /**
+ * speed optimized comparison of size string
+ *
+ * @param cache
+ * @return
+ */
+ private static int getSize(final cgCache cache) {
+ char c = cache.size.charAt(0);
+ switch (c) {
+ case 'm': // micro
+ return 1;
+ case 's': // small
+ return 2;
+ case 'r': // regular
+ return 3;
+ case 'l': // large
+ return 4;
+ default:
+ return 0;
+ }
+ }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/sorting/StateComparator.java b/src/cgeo/geocaching/sorting/StateComparator.java
index 787af5a..232fa92 100644
--- a/src/cgeo/geocaching/sorting/StateComparator.java
+++ b/src/cgeo/geocaching/sorting/StateComparator.java
@@ -4,29 +4,29 @@ import cgeo.geocaching.cgCache;
/**
* sort caches by state (normal, disabled, archived)
- *
+ *
*/
public class StateComparator extends AbstractCacheComparator implements
- CacheComparator {
+ CacheComparator {
- @Override
- protected boolean canCompare(final cgCache cache1, final cgCache cache2) {
- return true;
- }
+ @Override
+ protected boolean canCompare(final cgCache cache1, final cgCache cache2) {
+ return true;
+ }
- @Override
- protected int compareCaches(final cgCache cache1, final cgCache cache2) {
- return getState(cache1) - getState(cache2);
- }
+ @Override
+ protected int compareCaches(final cgCache cache1, final cgCache cache2) {
+ return getState(cache1) - getState(cache2);
+ }
- private static int getState(final cgCache cache) {
- if (cache.disabled) {
- return 1;
- }
- if (cache.archived) {
- return 2;
- }
- return 0;
- }
+ private static int getState(final cgCache cache) {
+ if (cache.disabled) {
+ return 1;
+ }
+ if (cache.archived) {
+ return 2;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/TerrainComparator.java b/src/cgeo/geocaching/sorting/TerrainComparator.java
index bf66af9..484889e 100644
--- a/src/cgeo/geocaching/sorting/TerrainComparator.java
+++ b/src/cgeo/geocaching/sorting/TerrainComparator.java
@@ -4,22 +4,22 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by terrain rating
- *
+ *
*/
public class TerrainComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.terrain != null && cache2.terrain != null;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.terrain != null && cache2.terrain != null;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- if (cache1.terrain > cache2.terrain) {
- return 1;
- } else if (cache2.terrain > cache1.terrain) {
- return -1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ if (cache1.terrain > cache2.terrain) {
+ return 1;
+ } else if (cache2.terrain > cache1.terrain) {
+ return -1;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/VisitComparator.java b/src/cgeo/geocaching/sorting/VisitComparator.java
index 79a8ac5..5dfeed4 100644
--- a/src/cgeo/geocaching/sorting/VisitComparator.java
+++ b/src/cgeo/geocaching/sorting/VisitComparator.java
@@ -4,23 +4,23 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by last visited date
- *
+ *
*/
public class VisitComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return cache1.visitedDate != null && cache1.visitedDate > 0
- && cache2.visitedDate != null && cache2.visitedDate > 0;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return cache1.visitedDate != null && cache1.visitedDate > 0
+ && cache2.visitedDate != null && cache2.visitedDate > 0;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- if (cache1.visitedDate > cache2.visitedDate) {
- return -1;
- } else if (cache1.visitedDate < cache2.visitedDate) {
- return 1;
- }
- return 0;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ if (cache1.visitedDate > cache2.visitedDate) {
+ return -1;
+ } else if (cache1.visitedDate < cache2.visitedDate) {
+ return 1;
+ }
+ return 0;
+ }
}
diff --git a/src/cgeo/geocaching/sorting/VoteComparator.java b/src/cgeo/geocaching/sorting/VoteComparator.java
index 0039c7c..181b19c 100644
--- a/src/cgeo/geocaching/sorting/VoteComparator.java
+++ b/src/cgeo/geocaching/sorting/VoteComparator.java
@@ -4,36 +4,36 @@ import cgeo.geocaching.cgCache;
/**
* sorts caches by the users own voting (if available at all)
- *
+ *
* @author bananeweizen
- *
+ *
*/
public class VoteComparator extends AbstractCacheComparator {
- @Override
- protected boolean canCompare(cgCache cache1, cgCache cache2) {
- return true;
- }
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return true;
+ }
- @Override
- protected int compareCaches(cgCache cache1, cgCache cache2) {
- // if there is no vote available, put that cache at the end of the list
- float vote1 = 0;
- if (cache1.myVote != null) {
- vote1 = cache1.myVote;
- }
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ // if there is no vote available, put that cache at the end of the list
+ float vote1 = 0;
+ if (cache1.myVote != null) {
+ vote1 = cache1.myVote;
+ }
- float vote2 = 0;
- if (cache2.myVote != null) {
- vote2 = cache2.myVote;
- }
+ float vote2 = 0;
+ if (cache2.myVote != null) {
+ vote2 = cache2.myVote;
+ }
- // compare
- if (vote1 < vote2) {
- return 1;
- } else if (vote2 < vote1) {
- return -1;
- }
- return 0;
- }
+ // compare
+ if (vote1 < vote2) {
+ return 1;
+ } else if (vote2 < vote1) {
+ return -1;
+ }
+ return 0;
+ }
}