Fixed search crash

This commit is contained in:
Alexey Kulish 2017-03-11 18:02:38 +03:00
parent b734cf76e2
commit 5bd4d5e37f

View file

@ -27,6 +27,7 @@ import net.osmand.plus.render.RenderingIcons;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
import java.io.File;
@ -193,8 +194,14 @@ public class QuickSearchListItem {
}
return typeStr;
case LOCATION:
LatLon latLon = (LatLon) searchResult.object;
if (searchResult.localeRelatedObjectName == null) {
LatLon latLon = null;
if (searchResult.object instanceof LatLon) {
latLon = (LatLon) searchResult.object;
} else if (searchResult.object instanceof GeoParsedPoint) {
GeoParsedPoint geoParsedPoint = (GeoParsedPoint) searchResult.object;
latLon = new LatLon(geoParsedPoint.getLatitude(), geoParsedPoint.getLongitude());
}
if (latLon != null && searchResult.localeRelatedObjectName == null) {
String locationCountry = app.getRegions().getCountryName(latLon);
searchResult.localeRelatedObjectName = locationCountry == null ? "" : locationCountry;
}