本文整理汇总了Java中com.mapbox.services.android.telemetry.location.LocationEngine类的典型用法代码示例。如果您正苦于以下问题:Java LocationEngine类的具体用法?Java LocationEngine怎么用?Java LocationEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocationEngine类属于com.mapbox.services.android.telemetry.location包,在下文中一共展示了LocationEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Before
public void setup() throws IOException {
MockitoAnnotations.initMocks(this);
navigation = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, mock(NavigationTelemetry.class),
mock(LocationEngine.class));
navigationEventDispatcher = navigation.getEventDispatcher();
Gson gson = new GsonBuilder()
.registerTypeAdapterFactory(DirectionsAdapterFactory.create()).create();
String body = loadJsonFixture(PRECISION_6);
DirectionsResponse response = gson.fromJson(body, DirectionsResponse.class);
route = response.routes().get(0);
routeProgress = RouteProgress.builder()
.stepDistanceRemaining(100)
.legDistanceRemaining(100)
.distanceRemaining(100)
.directionsRoute(route)
.stepIndex(0)
.legIndex(0)
.build();
}
示例2: onMapReady
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Override
public void onMapReady(final MapboxMap mapboxMap) {
LocationEngine locationEngine = new LostLocationEngine(this);
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.COMPASS);
locationLayerPlugin.addCompassListener(new CompassListener() {
@Override
public void onCompassChanged(float userHeading) {
CameraPosition cameraPosition = new CameraPosition.Builder().bearing(userHeading).build();
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
@Override
public void onCompassAccuracyChange(int compassStatus) {
System.out.println(compassStatus);
}
});
}
示例3: activateMockLocationEngine
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
/**
* Activates a new {@link MockLocationEngine} with the given
* {@link DirectionsRoute}.
*
* @param route to be mocked
*/
private void activateMockLocationEngine(DirectionsRoute route) {
LocationEngine locationEngine = new MockLocationEngine(1000, 30, false);
((MockLocationEngine) locationEngine).setRoute(route);
locationEngine.activate();
this.locationEngine.setValue(locationEngine);
}
示例4: initialize
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
void initialize(@NonNull Context context, @NonNull String accessToken,
MapboxNavigation navigation, LocationEngine locationEngine) {
if (!isInitialized) {
// Initial session state
navigationSessionState = SessionState.builder().build();
// Setup the location engine
updateLocationEngine(locationEngine);
validateAccessToken(accessToken);
// Setup the listeners
initEventDispatcherListeners(navigation);
MapboxNavigationOptions options = navigation.options();
// Set sdkIdentifier based on if from UI or not
String sdkIdentifier = updateSdkIdentifier(options);
// Enable extra logging in debug mode
MapboxTelemetry.getInstance().setDebugLoggingEnabled(options.isDebugLoggingEnabled());
updateUserAgent(context, accessToken, sdkIdentifier);
// Get the current vendorId
vendorId = obtainVendorId(context);
NavigationMetricsWrapper.sdkIdentifier = sdkIdentifier;
NavigationMetricsWrapper.turnstileEvent();
// TODO This should be removed when we figure out a solution in NavigationTelemetry
// Force pushing a TYPE_MAP_LOAD event to ensure that the Nav turnstile event is sent
MapboxTelemetry.getInstance().pushEvent(MapboxEvent.buildMapLoadEvent());
isInitialized = true;
}
}
示例5: updateLocationEngine
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
/**
* Called during {@link NavigationTelemetry#initialize(Context, String, MapboxNavigation, LocationEngine)}
* and any time {@link MapboxNavigation} gets an updated location engine.
* <p>
* Removes the current location engine listener if it exists, then
* sets up the new one / updates the location engine name.
*
* @param locationEngine to be used to update
*/
void updateLocationEngine(LocationEngine locationEngine) {
// Remove listener from previous engine
if (navigationLocationEngine != null) {
navigationLocationEngine.removeLocationEngineListener(this);
}
// Store the new engine and setup a new listener
if (locationEngine != null) {
navigationLocationEngine = locationEngine;
navigationLocationEngine.addLocationEngineListener(this);
String locationEngineName = locationEngine.getClass().getName();
navigationSessionState.toBuilder().locationEngineName(locationEngineName);
}
}
示例6: MapboxNavigation
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
MapboxNavigation(@NonNull Context context, @NonNull String accessToken,
@NonNull MapboxNavigationOptions options, NavigationTelemetry navigationTelemetry,
LocationEngine locationEngine) {
this.accessToken = accessToken;
this.context = context;
this.options = options;
this.navigationTelemetry = navigationTelemetry;
this.locationEngine = locationEngine;
initialize();
}
示例7: obtainLocationEngine
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
private LocationEngine obtainLocationEngine() {
if (locationEngine == null) {
return new LostLocationEngine(context);
}
return locationEngine;
}
示例8: sanityTest
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void sanityTest() {
assertNotNull("should not be null", navigation);
MapboxNavigationOptions options = MapboxNavigationOptions.builder().build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
assertNotNull("should not be null", navigationWithOptions);
}
示例9: defaultMilestones_onInitializationDoNotGetAdded
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void defaultMilestones_onInitializationDoNotGetAdded() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
assertEquals(0, navigationWithOptions.getMilestones().size());
}
示例10: addMilestone_milestoneOnlyGetsAddedOnce
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void addMilestone_milestoneOnlyGetsAddedOnce() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(milestone);
navigationWithOptions.addMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
}
示例11: removeMilestone_milestoneDidGetRemoved
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void removeMilestone_milestoneDidGetRemoved() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
navigationWithOptions.removeMilestone(milestone);
assertEquals(0, navigationWithOptions.getMilestones().size());
}
示例12: removeMilestone_milestoneDoesNotExist
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void removeMilestone_milestoneDoesNotExist() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
navigationWithOptions.removeMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
}
示例13: removeMilestone_nullRemovesAllMilestones
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void removeMilestone_nullRemovesAllMilestones() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
assertEquals(4, navigationWithOptions.getMilestones().size());
navigationWithOptions.removeMilestone(null);
assertEquals(0, navigationWithOptions.getMilestones().size());
}
示例14: removeMilestone_correctMilestoneWithIdentifierGetsRemoved
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void removeMilestone_correctMilestoneWithIdentifierGetsRemoved() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().setIdentifier(5678).build();
navigationWithOptions.addMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
navigationWithOptions.removeMilestone(5678);
assertEquals(0, navigationWithOptions.getMilestones().size());
}
示例15: removeMilestone_noMilestoneWithIdentifierFound
import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
@Test
public void removeMilestone_noMilestoneWithIdentifierFound() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class),
ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
assertEquals(1, navigationWithOptions.getMilestones().size());
navigationWithOptions.removeMilestone(5678);
assertEquals(1, navigationWithOptions.getMilestones().size());
}