Search in sources :

Example 1 with RegionAddressRepository

use of net.osmand.plus.resources.RegionAddressRepository in project Osmand by osmandapp.

the class QuickSearchDialogFragment method completeQueryWithObject.

public void completeQueryWithObject(SearchResult sr) {
    if (sr.object instanceof PoiType && ((PoiType) sr.object).isAdditional()) {
        PoiType additional = (PoiType) sr.object;
        AbstractPoiType parent = additional.getParentType();
        if (parent != null) {
            PoiUIFilter custom = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + parent.getKeyName());
            if (custom != null) {
                custom.clearFilter();
                custom.updateTypesToAccept(parent);
                custom.setFilterByName(additional.getKeyName().replace('_', ':').toLowerCase());
                SearchPhrase phrase = searchUICore.getPhrase();
                sr = new SearchResult(phrase);
                sr.localeName = custom.getName();
                sr.object = custom;
                sr.priority = SEARCH_AMENITY_TYPE_PRIORITY;
                sr.priorityDistance = 0;
                sr.objectType = ObjectType.POI_TYPE;
            }
        }
    }
    searchUICore.selectSearchResult(sr);
    if (addressSearch) {
        startAddressSearch();
        if (sr.objectType == ObjectType.CITY) {
            if (sr.relatedObject != null && sr.relatedObject instanceof BinaryMapIndexReader) {
                File f = ((BinaryMapIndexReader) sr.relatedObject).getFile();
                if (f != null) {
                    RegionAddressRepository region = app.getResourceManager().getRegionRepository(f.getName());
                    if (region != null) {
                        app.getSettings().setLastSearchedRegion(region.getFileName(), region.getEstimatedRegionCenter());
                        City city = (City) sr.object;
                        app.getSettings().setLastSearchedCity(city.getId(), sr.localeName, city.getLocation());
                    }
                }
            }
        }
    }
    String txt = searchUICore.getPhrase().getText(true);
    replaceQueryWithText(txt);
    if (sr.objectType == ObjectType.CITY) {
        openKeyboard();
    }
}
Also used : RegionAddressRepository(net.osmand.plus.resources.RegionAddressRepository) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) SearchResult(net.osmand.search.core.SearchResult) City(net.osmand.data.City) SpannableString(android.text.SpannableString) AbstractPoiType(net.osmand.osm.AbstractPoiType) File(java.io.File) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) SearchPhrase(net.osmand.search.core.SearchPhrase) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Aggregations

SpannableString (android.text.SpannableString)1 File (java.io.File)1 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)1 City (net.osmand.data.City)1 AbstractPoiType (net.osmand.osm.AbstractPoiType)1 PoiType (net.osmand.osm.PoiType)1 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)1 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)1 RegionAddressRepository (net.osmand.plus.resources.RegionAddressRepository)1 SearchPhrase (net.osmand.search.core.SearchPhrase)1 SearchResult (net.osmand.search.core.SearchResult)1