当前位置: 首页>>代码示例>>Java>>正文


Java LocationEngine类代码示例

本文整理汇总了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();
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:22,代码来源:NavigationEventDispatcherTest.java

示例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);
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:19,代码来源:CompassListenerActivity.java

示例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);
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:13,代码来源:LocationViewModel.java

示例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;
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:36,代码来源:NavigationTelemetry.java

示例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);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:24,代码来源:NavigationTelemetry.java

示例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();
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:11,代码来源:MapboxNavigation.java

示例7: obtainLocationEngine

import com.mapbox.services.android.telemetry.location.LocationEngine; //导入依赖的package包/类
private LocationEngine obtainLocationEngine() {
  if (locationEngine == null) {
    return new LostLocationEngine(context);
  }

  return locationEngine;
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:8,代码来源:MapboxNavigation.java

示例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);
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:9,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:8,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:11,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:12,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:11,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:14,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:12,代码来源:MapboxNavigationTest.java

示例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());
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:11,代码来源:MapboxNavigationTest.java


注:本文中的com.mapbox.services.android.telemetry.location.LocationEngine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。