From aaacbc9166350642caca4fed50e2c992d7aa2f10 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 24 Jun 2012 13:40:35 +0200 Subject: [PATCH] Fix sorting poi and favorite groups --- OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java | 11 ++++++++++- .../osmand/plus/activities/FavouritesActivity.java | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java index ac42530912..32bb6f6d81 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java @@ -1,8 +1,10 @@ package net.osmand.plus; +import java.text.Collator; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -141,10 +143,17 @@ public class PoiFiltersHelper { public List getOsmDefinedPoiFilters(){ if(cacheOsmDefinedFilters == null){ cacheOsmDefinedFilters = new ArrayList(); - cacheOsmDefinedFilters.add(new PoiFilter(null, application)); for(AmenityType t : AmenityType.values()){ cacheOsmDefinedFilters.add(new PoiFilter(t, application)); } + final Collator instance = Collator.getInstance(); + Collections.sort(cacheOsmDefinedFilters, new Comparator() { + @Override + public int compare(PoiFilter object1, PoiFilter object2) { + return instance.compare(object1.getName(), object2.getName()); + } + }); + cacheOsmDefinedFilters.add(0, new PoiFilter(null, application)); } return Collections.unmodifiableList(cacheOsmDefinedFilters); } diff --git a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java index 317c683dd3..7ecbe2315d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavouritesActivity.java @@ -14,6 +14,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import net.osmand.FavouritePoint; import net.osmand.GPXUtilities; @@ -462,7 +463,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity { List groups = new ArrayList(); public void setFavoriteGroups(Map> favoriteGroups) { - this.sourceFavoriteGroups = favoriteGroups; + this.sourceFavoriteGroups = new TreeMap>(favoriteGroups); synchronizeGroups(); }