Search in sources :

Example 6 with MapboxNavigation

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

the class RerouteActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reroute);
    ButterKnife.bind(this);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    // Initialize MapboxNavigation and add listeners
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().isDebugLoggingEnabled(true).build();
    navigation = new MapboxNavigation(getApplicationContext(), Mapbox.getAccessToken(), options);
    navigation.addNavigationEventListener(this);
    navigation.addMilestoneEventListener(this);
}
Also used : MapboxNavigationOptions(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)

Example 7 with MapboxNavigation

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

the class NavigationCameraTest method onStartWithNullRoute_progressListenerIsAdded.

@Test
public void onStartWithNullRoute_progressListenerIsAdded() throws Exception {
    MapboxNavigation navigation = mock(MapboxNavigation.class);
    ProgressChangeListener listener = mock(ProgressChangeListener.class);
    NavigationCamera camera = buildCamera(navigation, listener);
    camera.start(null);
    verify(navigation, times(1)).addProgressChangeListener(listener);
}
Also used : ProgressChangeListener(com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) Test(org.junit.Test)

Example 8 with MapboxNavigation

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

the class NavigationTelemetry method updateFeedbackEvent.

/**
 * Updates an existing feedback event generated by {@link MapboxNavigation#recordFeedback(String, String, String)}.
 * <p>
 * Uses a feedback ID to find the correct event and then adjusts the feedbackType and description.
 *
 * @param feedbackId   generated from {@link MapboxNavigation#recordFeedback(String, String, String)}
 * @param feedbackType from list of set feedback types
 * @param description  an optional description to provide more detail about the feedback
 * @param screenshot   an optional encoded screenshot to provide more detail about the feedback
 */
void updateFeedbackEvent(String feedbackId, @FeedbackEvent.FeedbackType String feedbackType, String description, String screenshot) {
    // Find the event and update
    FeedbackEvent feedbackEvent = (FeedbackEvent) findQueuedTelemetryEvent(feedbackId);
    if (feedbackEvent != null) {
        feedbackEvent.setFeedbackType(feedbackType);
        feedbackEvent.setDescription(description);
        feedbackEvent.setScreenshot(screenshot);
    }
}
Also used : FeedbackEvent(com.mapbox.services.android.navigation.v5.navigation.metrics.FeedbackEvent)

Example 9 with MapboxNavigation

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

the class NavigationTelemetry method updateSessionRoute.

/**
 * Called when a new {@link DirectionsRoute} is given in
 * {@link MapboxNavigation#startNavigation(DirectionsRoute)}.
 * <p>
 * At this point, navigation has already begun and the {@link SessionState}
 * needs to be updated.
 *
 * @param directionsRoute new route passed to {@link MapboxNavigation}
 */
void updateSessionRoute(DirectionsRoute directionsRoute) {
    SessionState.Builder navigationBuilder = navigationSessionState.toBuilder();
    navigationBuilder.currentDirectionRoute(directionsRoute);
    if (isOffRoute) {
        // If we are off-route, update the reroute count
        navigationBuilder.rerouteCount(navigationSessionState.rerouteCount() + 1);
        boolean hasRouteOptions = directionsRoute.routeOptions() != null;
        navigationBuilder.requestIdentifier(hasRouteOptions ? directionsRoute.routeOptions().requestUuid() : null);
        navigationSessionState = navigationBuilder.build();
        updateLastRerouteEvent(directionsRoute);
        lastRerouteDate = new Date();
        isOffRoute = false;
    } else {
        // Not current off-route - just update the session
        navigationSessionState = navigationBuilder.build();
    }
}
Also used : SessionState(com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState) Date(java.util.Date)

Example 10 with MapboxNavigation

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

the class NavigationCameraTest method onResumeWithNullLocation_progressListenerIsAdded.

@Test
public void onResumeWithNullLocation_progressListenerIsAdded() throws Exception {
    MapboxNavigation navigation = mock(MapboxNavigation.class);
    ProgressChangeListener listener = mock(ProgressChangeListener.class);
    NavigationCamera camera = buildCamera(navigation, listener);
    camera.resume(null);
    verify(navigation, times(1)).addProgressChangeListener(listener);
}
Also used : ProgressChangeListener(com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)6 Context (android.content.Context)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)5 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)2 FeedbackEvent (com.mapbox.services.android.navigation.v5.navigation.metrics.FeedbackEvent)2 ProgressChangeListener (com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener)2 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)2 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 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 SessionState (com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1 Date (java.util.Date)1