use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class SearchPoiFilterFragment method getFilters.
public List<Object> getFilters(String s) {
List<Object> filters = new ArrayList<Object>();
OsmandApplication app = getApp();
if (app == null) {
return filters;
}
PoiFiltersHelper poiFilters = app.getPoiFilters();
if (Algorithms.isEmpty(s)) {
filters.addAll(poiFilters.getTopDefinedPoiFilters());
} else {
for (PoiUIFilter pf : poiFilters.getTopDefinedPoiFilters()) {
if (!pf.isStandardFilter() && pf.getName().toLowerCase().startsWith(s.toLowerCase())) {
filters.add(pf);
}
}
List<AbstractPoiType> res = app.getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
final Collator inst = Collator.getInstance();
Collections.sort(res, new Comparator<AbstractPoiType>() {
@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());
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
filters.add(poiFilters.getNominatimPOIFilter());
filters.add(poiFilters.getNominatimAddressFilter());
}
}
return filters;
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class ShowHidePoiAction method execute.
@Override
public void execute(MapActivity activity) {
PoiFiltersHelper pf = activity.getMyApplication().getPoiFilters();
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
if (!isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters)) {
pf.clearSelectedPoiFilters();
for (PoiUIFilter filter : poiFilters) {
pf.addSelectedPoiFilter(filter);
}
} else
pf.clearSelectedPoiFilters();
activity.getMapLayers().updateLayers(activity.getMapView());
}
use of net.osmand.plus.poi.PoiFiltersHelper in project Osmand by osmandapp.
the class QuickSearchHelper method refreshCustomPoiFilters.
public void refreshCustomPoiFilters() {
core.clearCustomSearchPoiFilters();
PoiFiltersHelper poiFilters = app.getPoiFilters();
for (CustomSearchPoiFilter udf : poiFilters.getUserDefinedPoiFilters()) {
core.addCustomSearchPoiFilter(udf, 0);
}
PoiUIFilter localWikiPoiFilter = poiFilters.getLocalWikiPOIFilter();
if (localWikiPoiFilter != null) {
core.addCustomSearchPoiFilter(localWikiPoiFilter, 1);
}
core.addCustomSearchPoiFilter(poiFilters.getShowAllPOIFilter(), 1);
}
Aggregations