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