Fix null pointer

This commit is contained in:
Victor Shcherb 2012-06-02 22:12:58 +02:00
parent b5598d3454
commit 3cf67d1fe0

View file

@ -131,12 +131,12 @@ public class SearchCityByNameActivity extends SearchByNameAbstractActivity<City>
public String getText(City obj) {
LatLon l = obj.getLocation();
if (getFilter().length() > 2 && locationToSearch != null && l != null) {
String name =obj.getName(region.useEnglishNames());
if(obj instanceof City){
name += " [" + OsmAndFormatter.toPublicString(((City) obj).getType(), this) + "]";
String name = obj.getName(region.useEnglishNames());
if (obj.getType() != null) {
name += " [" + OsmAndFormatter.toPublicString(obj.getType(), this) + "]";
}
return name+ " - " + //$NON-NLS-1$
OsmAndFormatter.getFormattedDistance((int) MapUtils.getDistance(l, locationToSearch), this);
return name + " - " + //$NON-NLS-1$
OsmAndFormatter.getFormattedDistance((int) MapUtils.getDistance(l, locationToSearch), this);
} else {
return obj.getName(region.useEnglishNames());
}