Fix issue 1362 - only show route double call buggy

This commit is contained in:
Victor Shcherb 2012-09-09 19:58:21 +02:00
parent 3353cfa4e4
commit ebf725457b
3 changed files with 15 additions and 20 deletions

View file

@ -926,14 +926,14 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
return zoomDelta; return zoomDelta;
} }
public void navigateToPoint(LatLon point){ public void navigateToPoint(LatLon point, boolean updateRoute){
if(point != null){ if(point != null){
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), null); settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), null);
} else { } else {
settings.clearPointToNavigate(); settings.clearPointToNavigate();
} }
if(routingHelper.isRouteBeingCalculated() || routingHelper.isRouteCalculated() || if(updateRoute && ( routingHelper.isRouteBeingCalculated() || routingHelper.isRouteCalculated() ||
routingHelper.isFollowingMode()) { routingHelper.isFollowingMode())) {
routingHelper.setFinalAndCurrentLocation(point, getLastKnownLocation(), routingHelper.getCurrentGPXRoute()); routingHelper.setFinalAndCurrentLocation(point, getLastKnownLocation(), routingHelper.getCurrentGPXRoute());
} }
mapLayers.getNavigationLayer().setPointToNavigate(point); mapLayers.getNavigationLayer().setPointToNavigate(point);

View file

@ -747,10 +747,10 @@ public class MapActivityActions implements DialogProvider {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(intent); mapActivity.startActivity(intent);
} else if (standardId == R.string.context_menu_item_navigate_point) { } else if (standardId == R.string.context_menu_item_navigate_point) {
mapActivity.navigateToPoint(new LatLon(latitude, longitude)); mapActivity.navigateToPoint(new LatLon(latitude, longitude), true);
} else if (standardId == R.string.context_menu_item_directions) { } else if (standardId == R.string.context_menu_item_directions) {
Location loc = mapActivity.getLastKnownLocation(); Location loc = mapActivity.getLastKnownLocation();
mapActivity.navigateToPoint(new LatLon(latitude, longitude)); mapActivity.navigateToPoint(new LatLon(latitude, longitude), false);
// always enable and follow and let calculate it (GPS is not accessible in garage) // always enable and follow and let calculate it (GPS is not accessible in garage)
getDirections(loc, true); getDirections(loc, true);
} else if (standardId == R.string.context_menu_item_show_route) { } else if (standardId == R.string.context_menu_item_show_route) {
@ -917,18 +917,15 @@ public class MapActivityActions implements DialogProvider {
} }
@Override @Override
public boolean onClick(MenuItem item) { public boolean onClick(MenuItem item) {
if (mapActivity.getMapLayers().getNavigationLayer().getPointToNavigate() != null) { if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) {
if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) { routingHelper.setFinalAndCurrentLocation(null, mapActivity.getLastKnownLocation(),
routingHelper.setFinalAndCurrentLocation(null, mapActivity.getLastKnownLocation(), routingHelper.getCurrentGPXRoute()); routingHelper.getCurrentGPXRoute());
// restore default mode // restore default mode
boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get()); boolean changed = settings.APPLICATION_MODE.set(settings.PREV_APPLICATION_MODE.get());
mapActivity.updateApplicationModeSettings(); mapActivity.updateApplicationModeSettings();
mapView.refreshMap(changed); mapView.refreshMap(changed);
} else {
mapActivity.navigateToPoint(null);
}
} else { } else {
mapActivity.navigateToPoint(new LatLon(mapView.getLatitude(), mapView.getLongitude())); mapActivity.navigateToPoint(null, true);
} }
mapView.refreshMap(); mapView.refreshMap();
return true; return true;

View file

@ -224,10 +224,8 @@ public class RoutingHelper {
locationProjection.setLatitude(project.getLatitude()); locationProjection.setLatitude(project.getLatitude());
locationProjection.setLongitude(project.getLongitude()); locationProjection.setLongitude(project.getLongitude());
// we need to update bearing too // we need to update bearing too
if (locationProjection.hasBearing()) { float bearingTo = locationProjection.bearingTo(nextLocation);
float bearingTo = locationProjection.bearingTo(nextLocation); locationProjection.setBearing(bearingTo);
locationProjection.setBearing(bearingTo);
}
} }
} }
lastFixedLocation = currentLocation; lastFixedLocation = currentLocation;