aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/cgCacheVisitComparator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgeo/geocaching/cgCacheVisitComparator.java')
-rw-r--r--src/cgeo/geocaching/cgCacheVisitComparator.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/cgeo/geocaching/cgCacheVisitComparator.java b/src/cgeo/geocaching/cgCacheVisitComparator.java
new file mode 100644
index 0000000..19a4b52
--- /dev/null
+++ b/src/cgeo/geocaching/cgCacheVisitComparator.java
@@ -0,0 +1,27 @@
+package cgeo.geocaching;
+
+import java.util.Comparator;
+import android.util.Log;
+
+public class cgCacheVisitComparator implements Comparator<cgCache> {
+
+ public int compare(cgCache cache1, cgCache cache2) {
+ try {
+ if (cache1.visitedDate == null || cache1.visitedDate <= 0 || cache2.visitedDate == null || cache2.visitedDate <= 0) {
+ return 0;
+ }
+
+ if (cache1.visitedDate > cache2.visitedDate) {
+ return -1;
+ } else if (cache1.visitedDate < cache2.visitedDate) {
+ return 1;
+ } else {
+ return 0;
+ }
+ } catch (Exception e) {
+ Log.e(cgSettings.tag, "cgCacheVisitComparator.compare: " + e.toString());
+ }
+
+ return 0;
+ }
+}