Search in sources :

Example 11 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class NavigationHelperTest method checkMilestones_onlyTriggeredMilestonesGetReturned.

@Test
public void checkMilestones_onlyTriggeredMilestonesGetReturned() throws Exception {
    RouteProgress routeProgress = routeProgressBuilder.legIndex(0).stepIndex(0).build();
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation mapboxNavigation = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 0)).setIdentifier(1001).build());
    mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 4)).setIdentifier(1002).build());
    List<Milestone> triggeredMilestones = checkMilestones(routeProgress, routeProgress, mapboxNavigation);
    assertEquals(1, triggeredMilestones.size());
    assertEquals(1001, triggeredMilestones.get(0).getIdentifier());
    assertNotSame(1002, triggeredMilestones.get(0).getIdentifier());
}
Also used : Context(android.content.Context) LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) GsonBuilder(com.google.gson.GsonBuilder) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 12 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class NavigationViewModel method initNavigation.

/**
 * Initializes {@link MapboxNavigation} and adds all views that implement listeners.
 */
private void initNavigation(Context context, MapboxNavigationOptions options) {
    navigation = new MapboxNavigation(context, Mapbox.getAccessToken(), options);
    addNavigationListeners();
}
Also used : MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)

Aggregations

Context (android.content.Context)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)5 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 Test (org.junit.Test)5 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)3 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)3 Notification (android.app.Notification)1 Location (android.location.Location)1 GsonBuilder (com.google.gson.GsonBuilder)1 CustomNavigationNotification (com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification)1 LocationValidator (com.mapbox.services.android.navigation.v5.location.LocationValidator)1 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1 OffRoute (com.mapbox.services.android.navigation.v5.offroute.OffRoute)1 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)1