diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2011-12-11 17:50:15 +0100 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2011-12-11 17:50:15 +0100 |
commit | 87e3b22abe6ecb9381dd7abb58819115e46b1ef2 (patch) | |
tree | a0f74332481f468dca455114c3cb523aabf8b409 /main/src/cgeo | |
parent | e2786b4359bcb252bd107b60eea8903a13ef6103 (diff) | |
download | cgeo-87e3b22abe6ecb9381dd7abb58819115e46b1ef2.zip cgeo-87e3b22abe6ecb9381dd7abb58819115e46b1ef2.tar.gz cgeo-87e3b22abe6ecb9381dd7abb58819115e46b1ef2.tar.bz2 |
fix #879: sort event only list by date by default
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index a380731..e0abcfb 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -28,6 +28,7 @@ import cgeo.geocaching.sorting.RatingComparator; import cgeo.geocaching.sorting.SizeComparator; import cgeo.geocaching.sorting.StateComparator; import cgeo.geocaching.sorting.TerrainComparator; +import cgeo.geocaching.sorting.VisitComparator; import cgeo.geocaching.sorting.VoteComparator; import cgeo.geocaching.utils.RunnableWithArgument; @@ -177,6 +178,8 @@ public class cgeocaches extends AbstractListActivity { setAdapter(); + setDateComparatorForEventList(); + if (cacheList == null) { showToast(res.getString(R.string.err_list_load_fail)); setMoreCaches(false); @@ -2609,6 +2612,30 @@ public class cgeocaches extends AbstractListActivity { } } + /** + * set date comparator for pure event lists + */ + private void setDateComparatorForEventList() { + if (CollectionUtils.isNotEmpty(cacheList)) { + boolean eventsOnly = true; + for (cgCache cache : cacheList) { + if (!cache.isEventCache()) { + eventsOnly = false; + break; + } + } + if (eventsOnly) { + adapter.setComparator(new DateComparator()); + } + else if (type == CacheListType.HISTORY) { + adapter.setComparator(new VisitComparator()); + } + else { + adapter.setComparator(null); + } + } + } + public static void startActivityNearest(final Context context, final Geopoint coordsNow) { final Intent cachesIntent = new Intent(context, cgeocaches.class); cachesIntent.putExtra(EXTRAS_LIST_TYPE, CacheListType.NEAREST); |