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