Search in sources :

Example 6 with PoiFiltersHelper

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;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) Collator(java.text.Collator) CollatorStringMatcher(net.osmand.CollatorStringMatcher) OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin)

Example 7 with PoiFiltersHelper

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());
}
Also used : PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 8 with PoiFiltersHelper

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);
}
Also used : CustomSearchPoiFilter(net.osmand.search.core.CustomSearchPoiFilter) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Aggregations

PoiFiltersHelper (net.osmand.plus.poi.PoiFiltersHelper)8 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)8 Button (android.widget.Button)4 ArrayList (java.util.ArrayList)4 DialogInterface (android.content.DialogInterface)3 Drawable (android.graphics.drawable.Drawable)3 AlertDialog (android.support.v7.app.AlertDialog)3 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)3 ContextMenuItem (net.osmand.plus.ContextMenuItem)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 View (android.view.View)2 Intent (android.content.Intent)1 Nullable (android.support.annotation.Nullable)1 AdapterView (android.widget.AdapterView)1 ImageButton (android.widget.ImageButton)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 Collator (java.text.Collator)1 CollatorStringMatcher (net.osmand.CollatorStringMatcher)1 LatLon (net.osmand.data.LatLon)1