LocationView: When parsing Geocoder result, extract postal code too.

This commit is contained in:
Andreas Schildbach 2018-12-21 18:55:11 +01:00
parent c87100498d
commit 0586301002

View file

@ -19,6 +19,7 @@ package de.schildbach.oeffi.directions;
import java.util.Locale; import java.util.Locale;
import com.google.common.base.Joiner;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import de.schildbach.oeffi.Constants; import de.schildbach.oeffi.Constants;
@ -454,14 +455,17 @@ public class LocationView extends FrameLayout implements LocationHelper.Callback
final Location location; final Location location;
final int maxAddressLineIndex = address.getMaxAddressLineIndex(); final int maxAddressLineIndex = address.getMaxAddressLineIndex();
if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) if (maxAddressLineIndex >= 2 && Strings.emptyToNull(address.getAddressLine(2)) != null) {
location = new Location(LocationType.ADDRESS, null, coord, address.getAddressLine(1), location = new Location(LocationType.ADDRESS, null, coord, address.getAddressLine(1),
address.getAddressLine(0)); address.getAddressLine(0));
else if (address.getThoroughfare() != null) } else if (address.getThoroughfare() != null) {
location = new Location(LocationType.ADDRESS, null, coord, address.getLocality(), address.getThoroughfare() final Joiner joiner = Joiner.on(' ').skipNulls();
+ (address.getFeatureName() != null ? " " + address.getFeatureName() : "")); location = new Location(LocationType.ADDRESS, null, coord,
else joiner.join(address.getPostalCode(), address.getLocality()),
joiner.join(address.getThoroughfare(), address.getFeatureName()));
} else {
location = new Location(LocationType.ADDRESS, null, coord); location = new Location(LocationType.ADDRESS, null, coord);
}
return location; return location;
} }