Search in sources :

Example 11 with NavigationSession

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

the class DestinationReachedMenu method show.

public static void show(MapActivity mapActivity) {
    if (!DestinationReachedMenuFragment.isExists()) {
        shown = true;
        NavigationSession carNavigationSession = mapActivity.getMyApplication().getCarNavigationSession();
        if (carNavigationSession == null || !carNavigationSession.hasStarted()) {
            DestinationReachedMenu menu = new DestinationReachedMenu(mapActivity);
            DestinationReachedMenuFragment.showInstance(menu);
        }
    }
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession)

Example 12 with NavigationSession

use of net.osmand.plus.auto.NavigationSession 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);
            }
        }
    }
}
Also used : Destination(androidx.car.app.navigation.model.Destination) NavigationScreen(net.osmand.plus.auto.NavigationScreen) Trip(androidx.car.app.navigation.model.Trip) TripHelper(net.osmand.plus.auto.TripHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) NavigationSession(net.osmand.plus.auto.NavigationSession) TravelEstimate(androidx.car.app.navigation.model.TravelEstimate)

Example 13 with NavigationSession

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

the class OsmandApplication method showToastMessage.

public void showToastMessage(final int msgId, final Object... args) {
    uiHandler.post(() -> {
        Toast.makeText(OsmandApplication.this, getString(msgId, args), Toast.LENGTH_LONG).show();
        NavigationSession carNavigationSession = this.carNavigationSession;
        if (carNavigationSession != null && carNavigationSession.hasStarted()) {
            CarToast.makeText(carNavigationSession.getCarContext(), getString(msgId, args), CarToast.LENGTH_LONG).show();
        }
    });
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession)

Example 14 with NavigationSession

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

the class OsmandApplication method showToastMessage.

public void showToastMessage(final String msg) {
    uiHandler.post(() -> {
        Toast.makeText(OsmandApplication.this, msg, Toast.LENGTH_LONG).show();
        NavigationSession carNavigationSession = this.carNavigationSession;
        if (carNavigationSession != null && carNavigationSession.hasStarted()) {
            CarToast.makeText(carNavigationSession.getCarContext(), msg, CarToast.LENGTH_LONG).show();
        }
    });
}
Also used : NavigationSession(net.osmand.plus.auto.NavigationSession)

Example 15 with NavigationSession

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

the class OsmandApplication method showShortToastMessage.

public void showShortToastMessage(final int msgId, final Object... args) {
    uiHandler.post(() -> {
        Toast.makeText(OsmandApplication.this, getString(msgId, args), Toast.LENGTH_SHORT).show();
        NavigationSession carNavigationSession = this.carNavigationSession;
        if (carNavigationSession != null && carNavigationSession.hasStarted()) {
            CarToast.makeText(carNavigationSession.getCarContext(), getString(msgId, args), CarToast.LENGTH_SHORT).show();
        }
    });
}
Also used : 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