use of net.osmand.plus.auto.NavigationScreen in project Osmand by osmandapp.
the class NavigationService method stopCarNavigation.
/**
* Stops navigation.
*/
public void stopCarNavigation() {
if (navigationManager != null) {
NavigationSession carNavigationSession = getApp().getCarNavigationSession();
if (carNavigationSession != null) {
NavigationScreen navigationScreen = carNavigationSession.getNavigationScreen();
if (navigationScreen != null) {
navigationScreen.stopTrip();
}
}
carNavigationActive = false;
navigationManager.navigationEnded();
}
}
use of net.osmand.plus.auto.NavigationScreen in project Osmand by osmandapp.
the class NavigationService method updateCarNavigation.
public void updateCarNavigation() {
OsmandApplication app = getApp();
RoutingHelper routingHelper = app.getRoutingHelper();
TripHelper tripHelper = this.tripHelper;
if (carNavigationActive && tripHelper != null && routingHelper.isRouteCalculated() && routingHelper.isFollowingMode()) {
NavigationSession carNavigationSession = app.getCarNavigationSession();
if (carNavigationSession != null) {
NavigationScreen navigationScreen = carNavigationSession.getNavigationScreen();
if (navigationScreen != null) {
float density = navigationScreen.getSurfaceRenderer().getDensity();
if (density == 0) {
density = 1;
}
Trip trip = tripHelper.buildTrip(density);
navigationManager.updateTrip(trip);
List<Destination> destinations = null;
Destination destination = tripHelper.getLastDestination();
TravelEstimate destinationTravelEstimate = tripHelper.getLastDestinationTravelEstimate();
if (destination != null) {
destinations = Collections.singletonList(destination);
}
TravelEstimate lastStepTravelEstimate = tripHelper.getLastStepTravelEstimate();
navigationScreen.updateTrip(true, routingHelper.isRouteBeingCalculated(), false, /*routingHelper.isRouteWasFinished()*/
destinations, trip.getSteps(), destinationTravelEstimate, lastStepTravelEstimate != null ? lastStepTravelEstimate.getRemainingDistance() : null, false, true, null);
}
}
}
}
Aggregations