Add extra type for search to display results faster

This commit is contained in:
Victor Shcherb 2016-07-15 10:07:38 +02:00
parent 4123776efd
commit 1f75f8f10e
3 changed files with 17 additions and 1 deletions

View file

@ -269,6 +269,16 @@ public class SearchUICore {
}
}
public void apiSearchRegionFinished(SearchCoreAPI api, BinaryMapIndexReader region, SearchPhrase phrase) {
if(matcher != null) {
SearchResult sr = new SearchResult(phrase);
sr.objectType = ObjectType.SEARCH_API_REGION_FINISHED;
sr.object = api;
sr.file = region;
matcher.publish(sr);
}
}
@Override
public boolean publish(SearchResult object) {
if(matcher == null || matcher.publish(object)) {

View file

@ -9,8 +9,10 @@ public enum ObjectType {
LOCATION(true), PARTIAL_LOCATION(false),
// UI OBJECTS
FAVORITE(true), WPT(true), RECENT_OBJ(true),
REGION(true),
SEARCH_API_FINISHED(false), UNKNOWN_NAME_FILTER(false);
SEARCH_API_FINISHED(false), SEARCH_API_REGION_FINISHED(false),
UNKNOWN_NAME_FILTER(false);
private boolean hasLocation;
private ObjectType(boolean location) {
this.hasLocation = location;

View file

@ -160,6 +160,7 @@ public class SearchCoreFactory {
// phrase.isLastWord(ObjectType.CITY, ObjectType.VILLAGE, ObjectType.POSTCODE) || phrase.isLastWord(ObjectType.REGION)
if (phrase.isNoSelectedType() || phrase.getRadiusLevel() >= 2) {
initAndSearchCities(phrase, resultMatcher);
resultMatcher.apiSearchFinished(this, phrase);
searchByName(phrase, resultMatcher);
}
return true;
@ -320,6 +321,7 @@ public class SearchCoreFactory {
req.setBBoxRadius(loc.getLatitude(), loc.getLongitude(), phrase.getRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS * 10));
}
r.searchAddressDataByName(req);
resultMatcher.apiSearchRegionFinished(this, r, phrase);
}
}
}
@ -376,6 +378,7 @@ public class SearchCoreFactory {
BinaryMapIndexReader r = offlineIterator.next();
currentFile[0] = r;
r.searchPoiByName(req);
resultMatcher.apiSearchRegionFinished(this, r, phrase);
}
return true;
}
@ -572,6 +575,7 @@ public class SearchCoreFactory {
for (BinaryMapIndexReader o : oo) {
selected[0] = o;
o.searchPoi(req);
resultMatcher.apiSearchRegionFinished(this, o, phrase);
}
}
return true;