use of net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry in project Osmand by osmandapp.
the class QuickSearchListFragment method showResult.
public void showResult(SearchResult searchResult) {
if (searchResult.location != null) {
OsmandApplication app = getMyApplication();
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
boolean transliterate = searchResult.requiredSearchPhrase.getSettings().isTransliterate();
PointDescription pointDescription = null;
Object object = searchResult.object;
switch(searchResult.objectType) {
case POI:
Amenity a = (Amenity) object;
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(a, lang, transliterate);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
pointDescription.setIconName(QuickSearchListItem.getAmenityIconName(app, a));
break;
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) object;
pointDescription = entry.getName();
if (pointDescription.isPoi()) {
Amenity amenity = app.getSearchUICore().findAmenity(entry.getName().getName(), entry.getLat(), entry.getLon(), lang, transliterate);
if (amenity != null) {
object = amenity;
pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI, OsmAndFormatter.getPoiStringWithoutType(amenity, lang, transliterate));
pointDescription.setIconName(QuickSearchListItem.getAmenityIconName(app, amenity));
}
} else if (pointDescription.isFavorite()) {
LatLon entryLatLon = new LatLon(entry.getLat(), entry.getLon());
List<FavouritePoint> favs = app.getFavorites().getFavouritePoints();
for (FavouritePoint f : favs) {
if (entryLatLon.equals(new LatLon(f.getLatitude(), f.getLongitude())) && pointDescription.getName().equals(f.getName())) {
object = f;
pointDescription = f.getPointDescription();
break;
}
}
}
break;
case FAVORITE:
FavouritePoint fav = (FavouritePoint) object;
pointDescription = fav.getPointDescription();
break;
case VILLAGE:
case CITY:
String cityName = searchResult.localeName;
String typeNameCity = QuickSearchListItem.getTypeName(app, searchResult);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameCity, cityName);
pointDescription.setIconName("ic_action_building_number");
break;
case STREET:
String streetName = searchResult.localeName;
String typeNameStreet = QuickSearchListItem.getTypeName(app, searchResult);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameStreet, streetName);
pointDescription.setIconName("ic_action_street_name");
break;
case HOUSE:
String typeNameHouse = null;
String name = searchResult.localeName;
if (searchResult.relatedObject instanceof City) {
name = ((City) searchResult.relatedObject).getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true) + " " + name;
} else if (searchResult.relatedObject instanceof Street) {
String s = ((Street) searchResult.relatedObject).getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
typeNameHouse = ((Street) searchResult.relatedObject).getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
name = s + " " + name;
} else if (searchResult.localeRelatedObjectName != null) {
name = searchResult.localeRelatedObjectName + " " + name;
}
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameHouse, name);
pointDescription.setIconName("ic_action_building");
break;
case LOCATION:
pointDescription = new PointDescription(searchResult.location.getLatitude(), searchResult.location.getLongitude());
pointDescription.setIconName("ic_action_world_globe");
break;
case STREET_INTERSECTION:
String typeNameIntersection = QuickSearchListItem.getTypeName(app, searchResult);
if (Algorithms.isEmpty(typeNameIntersection)) {
typeNameIntersection = null;
}
pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeNameIntersection, QuickSearchListItem.getName(app, searchResult));
pointDescription.setIconName("ic_action_intersection");
break;
case WPT:
GPXUtilities.WptPt wpt = (GPXUtilities.WptPt) object;
pointDescription = wpt.getPointDescription(getMyApplication());
break;
}
dialogFragment.hideToolbar();
dialogFragment.hide();
showOnMap(getMapActivity(), dialogFragment, searchResult.location.getLatitude(), searchResult.location.getLongitude(), searchResult.preferredZoom, pointDescription, object);
}
}
Aggregations