diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index d2f14e9f36..48a568ad1a 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -1,7 +1,9 @@ package net.osmand.osm; +import net.osmand.CollatorStringMatcher; import net.osmand.PlatformUtil; import net.osmand.StringMatcher; +import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.data.Amenity; import net.osmand.util.Algorithms; @@ -166,8 +168,8 @@ public class MapPoiTypes { return translation; } - public Map getAllTypesTranslatedNames(StringMatcher matcher) { - Map tm = new TreeMap(Collator.getInstance()); + public List getAllTypesTranslatedNames(StringMatcher matcher) { + List tm = new ArrayList(); for (PoiCategory pc : categories) { if(pc == otherMapCategory) { continue; @@ -187,9 +189,9 @@ public class MapPoiTypes { return tm; } - private void addIf(Map tm, AbstractPoiType pc, StringMatcher matcher) { + private void addIf(List tm, AbstractPoiType pc, StringMatcher matcher) { if(matcher.matches(pc.getTranslation()) || matcher.matches(pc.getKeyName().replace('_', ' '))) { - tm.put(pc.getTranslation(), pc); + tm.add(pc); } List additionals = pc.getPoiAdditionals(); if (additionals != null) { @@ -502,10 +504,10 @@ public class MapPoiTypes { List lf = DEFAULT_INSTANCE.getTopVisibleFilters(); for(PoiFilter l : lf) { System.out.println("----------------- " + l.getKeyName()); - print("", l); +// print("", l); Map> m = l.putTypes(new LinkedHashMap>()); - System.out.println(m); +// System.out.println(m); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java index 7c80a1ba7e..cb21eb976f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterFragment.java @@ -3,7 +3,10 @@ */ package net.osmand.plus.activities.search; +import java.text.Collator; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; @@ -139,9 +142,17 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc filters.add(pf); } } - Map res = + List res = app.getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE)); - for(AbstractPoiType p : res.values()) { + final Collator inst = Collator.getInstance(); + Collections.sort(res, new Comparator() { + @Override + public int compare(AbstractPoiType lhs, AbstractPoiType rhs) { + return inst.compare(lhs.getTranslation(), rhs.getTranslation()); + } + + }); + for(AbstractPoiType p : res) { filters.add(p); } filters.add(poiFilters.getSearchByNamePOIFilter());