diff options
| author | mucek4 <tomaz@gorenc.org> | 2011-07-11 08:12:48 +0200 |
|---|---|---|
| committer | mucek4 <tomaz@gorenc.org> | 2011-07-11 08:12:48 +0200 |
| commit | 3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d (patch) | |
| tree | 6109c451668d4517785e8225c06230b7f02d1414 /src/cgeo/geocaching/cgCacheGeocodeComparator.java | |
| download | cgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.zip cgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.tar.gz cgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.tar.bz2 | |
First commit
Diffstat (limited to 'src/cgeo/geocaching/cgCacheGeocodeComparator.java')
| -rw-r--r-- | src/cgeo/geocaching/cgCacheGeocodeComparator.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cgeo/geocaching/cgCacheGeocodeComparator.java b/src/cgeo/geocaching/cgCacheGeocodeComparator.java new file mode 100644 index 0000000..e06d9f3 --- /dev/null +++ b/src/cgeo/geocaching/cgCacheGeocodeComparator.java @@ -0,0 +1,26 @@ +package cgeo.geocaching; + +import java.util.Comparator; +import android.util.Log; + +public class cgCacheGeocodeComparator implements Comparator<cgCache> { + + public int compare(cgCache cache1, cgCache cache2) { + try { + if (cache1.geocode == null || cache1.geocode.length() <= 0 || cache2.geocode == null || cache2.geocode.length() <= 0) { + return 0; + } + + if (cache1.geocode.length() > cache2.geocode.length()) { + return 1; + } else if (cache2.geocode.length() > cache1.geocode.length()) { + return -1; + } else { + return cache1.geocode.compareToIgnoreCase(cache2.geocode); + } + } catch (Exception e) { + Log.e(cgSettings.tag, "cgCacheGeocodeComparator.compare: " + e.toString()); + } + return 0; + } +} |
