diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index 5a4947a092..62594e034e 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -16,6 +16,7 @@ import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.LatLon; import net.osmand.osm.MapPoiTypes; +import net.osmand.search.core.ObjectType; import net.osmand.search.core.SearchCoreAPI; import net.osmand.search.core.SearchCoreFactory; import net.osmand.search.core.SearchPhrase; @@ -202,6 +203,7 @@ public class SearchUICore { } try { api.search(phrase, matcher); + matcher.apiSearchFinished(api, phrase); } catch (Throwable e) { e.printStackTrace(); LOG.error(e.getMessage(), e); @@ -213,7 +215,7 @@ public class SearchUICore { - private void sortSearchResults(SearchPhrase sp, List searchResults) { + public void sortSearchResults(SearchPhrase sp, List searchResults) { // sort SearchResult by 1. searchDistance 2. Name final LatLon loc = sp.getLastTokenLocation(); final net.osmand.Collator clt = OsmAndCollator.primaryCollator(); @@ -258,6 +260,15 @@ public class SearchUICore { return requestResults; } + public void apiSearchFinished(SearchCoreAPI api, SearchPhrase phrase) { + if(matcher != null) { + SearchResult sr = new SearchResult(phrase); + sr.objectType = ObjectType.SEARCH_API_FINISHED; + sr.object = api; + matcher.publish(sr); + } + } + @Override public boolean publish(SearchResult object) { if(matcher == null || matcher.publish(object)) { diff --git a/OsmAnd-java/src/net/osmand/search/core/ObjectType.java b/OsmAnd-java/src/net/osmand/search/core/ObjectType.java index 8154fffd19..6a7b24f551 100644 --- a/OsmAnd-java/src/net/osmand/search/core/ObjectType.java +++ b/OsmAnd-java/src/net/osmand/search/core/ObjectType.java @@ -3,6 +3,7 @@ package net.osmand.search.core; public enum ObjectType { CITY(true), VILLAGE(true), POSTCODE(true), STREET(true), HOUSE(true), STREET_INTERSECTION(true), POI_TYPE(false), POI(true), LOCATION(true), PARTIAL_LOCATION(false), FAVORITE(true), + SEARCH_API_FINISHED(false), REGION(true), RECENT_OBJ(true), WPT(true), UNKNOWN_NAME_FILTER(false); private boolean hasLocation; private ObjectType(boolean location) { diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index 7f4124690e..364e06351a 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -812,7 +812,7 @@ public class SearchCoreFactory { sp.objectType = ObjectType.LOCATION; sp.wordsSpan = 2; resultMatcher.publish(sp); - } else { + } else if (phrase.isNoSelectedType()) { SearchResult sp = new SearchResult(phrase); sp.priority = 0; sp.object = sp.location = new LatLon(dd, 0);