Search in sources :

Example 16 with NavigationSession

use of net.osmand.plus.auto.NavigationSession in project Osmand by osmandapp.

the class OsmAndLocationProvider method setLocationFromService.

public void setLocationFromService(net.osmand.Location location) {
    if (locationSimulation.isRouteAnimating() || shouldIgnoreLocation(location)) {
        return;
    }
    if (location != null) {
        lastTimeLocationFixed = System.currentTimeMillis();
        notifyGpsLocationRecovered();
    }
    // notify about lost location
    scheduleCheckIfGpsLost(location);
    RoutingHelper routingHelper = app.getRoutingHelper();
    app.getSavingTrackHelper().updateLocation(location, heading);
    OsmandPlugin.updateLocationPlugins(location);
    routingHelper.updateLocation(location);
    app.getWaypointHelper().locationChanged(location);
    NavigationSession carNavigationSession = app.getCarNavigationSession();
    if (carNavigationSession != null && carNavigationSession.hasStarted()) {
        carNavigationSession.updateLocation(location);
        net.osmand.Location updatedLocation = location;
        if (routingHelper.isFollowingMode()) {
            if (location == null || isPointAccurateForRouting(location)) {
                // Update routing position and get location for sticking mode
                updatedLocation = routingHelper.setCurrentLocation(location, app.getSettings().SNAP_TO_ROAD.get());
            }
        }
        this.location = updatedLocation;
        updateLocation(this.location);
    }
}
Also used : RoutingHelper(net.osmand.plus.routing.RoutingHelper) NavigationSession(net.osmand.plus.auto.NavigationSession)

Aggregations

NavigationSession (net.osmand.plus.auto.NavigationSession)16 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 Location (net.osmand.Location)2 NavigationService (net.osmand.plus.NavigationService)2 NavigationScreen (net.osmand.plus.auto.NavigationScreen)2 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)2 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 ViewStub (android.view.ViewStub)1 TextView (android.widget.TextView)1 Destination (androidx.car.app.navigation.model.Destination)1 TravelEstimate (androidx.car.app.navigation.model.TravelEstimate)1 Trip (androidx.car.app.navigation.model.Trip)1 CarAppExtender (androidx.car.app.notification.CarAppExtender)1 CarPendingIntent (androidx.car.app.notification.CarPendingIntent)1 BigTextStyle (androidx.core.app.NotificationCompat.BigTextStyle)1