mirror of
https://gitlab.com/oeffi/oeffi.git
synced 2025-07-08 09:08:47 +00:00
DirectionsShortcutActivity: Use LocationView.addressToLocation() for parsing Geocoder results too.
This commit is contained in:
parent
0586301002
commit
653c5afad1
1 changed files with 6 additions and 32 deletions
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
package de.schildbach.oeffi.directions;
|
package de.schildbach.oeffi.directions;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
|
@ -169,44 +168,19 @@ public class DirectionsShortcutActivity extends OeffiActivity
|
||||||
public void onLocation(final Point here) {
|
public void onLocation(final Point here) {
|
||||||
new GeocoderThread(DirectionsShortcutActivity.this, here, new GeocoderThread.Callback() {
|
new GeocoderThread(DirectionsShortcutActivity.this, here, new GeocoderThread.Callback() {
|
||||||
public void onGeocoderResult(final Address address) {
|
public void onGeocoderResult(final Address address) {
|
||||||
final String resolved = extractAddress(address);
|
final Location location = LocationView.addressToLocation(address);
|
||||||
if (resolved != null)
|
query(location);
|
||||||
query(here, resolved);
|
|
||||||
else
|
|
||||||
query(here);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGeocoderFail(final Exception exception) {
|
public void onGeocoderFail(final Exception exception) {
|
||||||
query(here);
|
final Location location = Location
|
||||||
}
|
.coord(Point.fromDouble(here.getLatAsDouble(), here.getLonAsDouble()));
|
||||||
|
query(location);
|
||||||
private String extractAddress(final Address address) {
|
|
||||||
final int maxAddressLineIndex = address.getMaxAddressLineIndex();
|
|
||||||
if (maxAddressLineIndex < 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i <= maxAddressLineIndex; i++) {
|
|
||||||
builder.append(address.getAddressLine(i));
|
|
||||||
builder.append(", ");
|
|
||||||
}
|
|
||||||
builder.setLength(builder.length() - 2);
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void query(final Point here) {
|
private void query(final Location from) {
|
||||||
final String hereName = String.format(Locale.ENGLISH, "%.6f, %.6f", here.getLatAsDouble(),
|
|
||||||
here.getLonAsDouble());
|
|
||||||
|
|
||||||
query(here, hereName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void query(final Point here, final String hereName) {
|
|
||||||
final Location from = new Location(LocationType.ADDRESS, null, here, null, hereName);
|
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
|
|
||||||
final NetworkProvider networkProvider = getNetworkExtra(intent);
|
final NetworkProvider networkProvider = getNetworkExtra(intent);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue