Fix sorting poi and favorite groups

This commit is contained in:
Victor Shcherb 2012-06-24 13:40:35 +02:00
parent dc36ac7e9e
commit aaacbc9166
2 changed files with 12 additions and 2 deletions

View file

@ -1,8 +1,10 @@
package net.osmand.plus; package net.osmand.plus;
import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -141,10 +143,17 @@ public class PoiFiltersHelper {
public List<PoiFilter> getOsmDefinedPoiFilters(){ public List<PoiFilter> getOsmDefinedPoiFilters(){
if(cacheOsmDefinedFilters == null){ if(cacheOsmDefinedFilters == null){
cacheOsmDefinedFilters = new ArrayList<PoiFilter>(); cacheOsmDefinedFilters = new ArrayList<PoiFilter>();
cacheOsmDefinedFilters.add(new PoiFilter(null, application));
for(AmenityType t : AmenityType.values()){ for(AmenityType t : AmenityType.values()){
cacheOsmDefinedFilters.add(new PoiFilter(t, application)); cacheOsmDefinedFilters.add(new PoiFilter(t, application));
} }
final Collator instance = Collator.getInstance();
Collections.sort(cacheOsmDefinedFilters, new Comparator<PoiFilter>() {
@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); return Collections.unmodifiableList(cacheOsmDefinedFilters);
} }

View file

@ -14,6 +14,7 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import net.osmand.FavouritePoint; import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
@ -462,7 +463,7 @@ public class FavouritesActivity extends OsmandExpandableListActivity {
List<String> groups = new ArrayList<String>(); List<String> groups = new ArrayList<String>();
public void setFavoriteGroups(Map<String, List<FavouritePoint>> favoriteGroups) { public void setFavoriteGroups(Map<String, List<FavouritePoint>> favoriteGroups) {
this.sourceFavoriteGroups = favoriteGroups; this.sourceFavoriteGroups = new TreeMap<String, List<FavouritePoint>>(favoriteGroups);
synchronizeGroups(); synchronizeGroups();
} }