Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-05-16 18:58:33 +02:00
commit 28c39d1d30
6 changed files with 60 additions and 25 deletions

View file

@ -49,16 +49,21 @@ public class CurrentPositionHelper {
p = GeneralRouterProfile.CAR;
}
BinaryMapIndexReader[] rs = new BinaryMapIndexReader[app.getResourceManager().getAddressRepositories().size()];
int i = 0;
for (RegionAddressRepository rep : app.getResourceManager().getAddressRepositories()) {
rs[i++] = rep.getFile();
if (rs.length > 0) {
int i = 0;
for (RegionAddressRepository rep : app.getResourceManager().getAddressRepositories()) {
rs[i++] = rep.getFile();
}
RoutingConfiguration cfg = app.getDefaultRoutingConfig().build(p.name().toLowerCase(), 10,
new HashMap<String, String>());
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, rs);
RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build(GeneralRouterProfile.CAR.name().toLowerCase(), 10,
new HashMap<String, String>());
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
} else {
ctx = null;
defCtx = null;
}
RoutingConfiguration cfg = app.getDefaultRoutingConfig().build(p.name().toLowerCase(), 10,
new HashMap<String, String>());
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, rs);
RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build(GeneralRouterProfile.CAR.name().toLowerCase(), 10,
new HashMap<String, String>());
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
}
private boolean scheduleRouteSegmentFind(final Location loc, final boolean storeFound, final ResultMatcher<GeocodingResult> geoCoding, final ResultMatcher<RouteDataObject> result) {

View file

@ -83,7 +83,8 @@ public class GeocodingLookupService {
lookupLocations.add(requestedLocation);
}
if (currentRequestedLocation == null) {
if (currentRequestedLocation == null && !lookupLocations.isEmpty()) {
currentRequestedLocation = lookupLocations.peek();
execute(new AddressLookupRequestsAsyncTask(app));
}
}

View file

@ -98,6 +98,15 @@ public class MapMarkersHelper {
settings.ROUTE_MAP_MARKERS_START_MY_LOC.set(startFromMyLocation);
}
public void lookupAddressAll() {
for (MapMarker mapMarker : mapMarkers) {
lookupAddress(mapMarker, false);
}
for (MapMarker mapMarker : mapMarkersHistory) {
lookupAddress(mapMarker, true);
}
}
private void readFromSettings() {
mapMarkers.clear();
mapMarkersHistory.clear();
@ -121,7 +130,6 @@ public class MapMarkersHelper {
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
pos, selections.get(i), i);
mapMarkers.add(mapMarker);
lookupAddress(mapMarker, false);
}
updateSortedArray();
@ -133,7 +141,10 @@ public class MapMarkersHelper {
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), 0, 0, false, i);
mapMarker.history = true;
mapMarkersHistory.add(mapMarker);
lookupAddress(mapMarker, true);
}
if (!ctx.isApplicationInitializing()) {
lookupAddressAll();
}
}

View file

@ -114,12 +114,17 @@ public class TargetPointsHelper {
readFromSettings();
}
public void lookupAddessAll() {
lookupAddressForPointToNavigate();
lookupAddessForStartPoint();
for(TargetPoint targetPoint : intermediatePoints) {
lookupAddressForIntermediatePoint(targetPoint);
}
}
private void readFromSettings() {
pointToNavigate = TargetPoint.create(settings.getPointToNavigate(), settings.getPointNavigateDescription());
lookupAddressForPointToNavigate();
pointToStart = TargetPoint.createStartPoint(settings.getPointToStart(), settings.getStartPointDescription());
lookupAddessForStartPoint();
intermediatePoints.clear();
List<LatLon> ips = settings.getIntermediatePoints();
@ -128,7 +133,10 @@ public class TargetPointsHelper {
final TargetPoint targetPoint = new TargetPoint(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), i);
intermediatePoints.add(targetPoint);
lookupAddressForIntermediatePoint(targetPoint);
}
if (!ctx.isApplicationInitializing()) {
lookupAddessAll();
}
}
@ -138,11 +146,14 @@ public class TargetPointsHelper {
AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
if (intermediatePoints.contains(targetPoint)) {
targetPoint.pointDescription.setName(address);
settings.updateIntermediatePoint(targetPoint.point.getLatitude(), targetPoint.point.getLongitude(),
targetPoint.pointDescription);
updateRouteAndRefresh(false);
for (TargetPoint p : intermediatePoints) {
if (p.point.equals(targetPoint.point)) {
p.pointDescription.setName(address);
settings.updateIntermediatePoint(p.point.getLatitude(), p.point.getLongitude(),
p.pointDescription);
updateRouteAndRefresh(false);
break;
}
}
}
}, null);

View file

@ -301,6 +301,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (dashboardOnMap != null) {
dashboardOnMap.updateLocation(true, true, false);
}
app.getTargetPointsHelper().lookupAddessAll();
app.getMapMarkersHelper().lookupAddressAll();
}
}

View file

@ -78,6 +78,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private AddressLookupRequest startPointRequest;
private AddressLookupRequest targetPointRequest;
private List<LatLon> intermediateRequestsLatLon = new ArrayList<>();
private OnMarkerSelectListener onMarkerSelectListener;
private OnDismissListener onDismissDialogListener;
@ -167,6 +168,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void showHideMenu() {
intermediateRequestsLatLon.clear();
if (isVisible()) {
hide();
} else {
@ -642,16 +644,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (i > 0) {
via.append(" ");
}
String description = points.get(i).getOnlyName();
via.append(getRoutePointDescription(points.get(i).point, description));
boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity);
TargetPoint p = points.get(i);
String description = p.getOnlyName();
via.append(getRoutePointDescription(p.point, description));
boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity)
&& !intermediateRequestsLatLon.contains(p.point);
if (needAddress) {
AddressLookupRequest lookupRequest = new AddressLookupRequest(points.get(i).point, new GeocodingLookupService.OnAddressLookupResult() {
AddressLookupRequest lookupRequest = new AddressLookupRequest(p.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
updateMenu();
}
}, null);
intermediateRequestsLatLon.add(p.point);
geocodingLookupService.lookupAddress(lookupRequest);
}
}