summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-12-07 17:00:36 +0200
committerTobrun <tobrun@mapbox.com>2018-12-10 16:59:50 +0100
commit8eaff9ce13b1a16bf347d27fde2d9ebfdd8665a4 (patch)
treee0086b3cb4792720e879feb380e5f0850e6f405f /platform/android
parent648f34aadc97df07026b89256afe8ae813baee81 (diff)
downloadqtlocation-mapboxgl-8eaff9ce13b1a16bf347d27fde2d9ebfdd8665a4.tar.gz
[android] - make style part of location component activation, add tests for non existing style and multiple style loading, revisit code comments
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java143
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java27
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java11
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java22
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java12
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt14
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java66
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt31
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt114
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt31
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt45
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt11
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java1
17 files changed, 355 insertions, 208 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
index 37433076b0..2391d6a86e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java
@@ -56,7 +56,7 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_T
* <p>
* <strong>
* To get the component object use {@link MapboxMap#getLocationComponent()} and activate it with
- * {@link #activateLocationComponent(Context)} or one of the overloads.
+ * {@link #activateLocationComponent(Context, Style)} or one of the overloads.
* Then, manage its visibility with {@link #setLocationComponentEnabled(boolean)}.
* </strong>
* <p>
@@ -77,7 +77,7 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.DEFAULT_T
* When using any engine, requesting/removing the location updates is going to be managed internally.
* <p>
* You can also push location updates to the component without any internal engine management.
- * To achieve that, use {@link #activateLocationComponent(Context, boolean)} with false.
+ * To achieve that, use {@link #activateLocationComponent(Context, Style, boolean)} with false.
* No engine is going to be initialized and you can push location updates with {@link #forceLocationUpdate(Location)}.
* <p>
* For location puck animation purposes, like navigation,
@@ -90,6 +90,7 @@ public final class LocationComponent {
@NonNull
private final MapboxMap mapboxMap;
+ private Style style;
private LocationComponentOptions options;
@NonNull
private InternalLocationEngineProvider internalLocationEngineProvider = new InternalLocationEngineProvider();
@@ -201,8 +202,8 @@ public final class LocationComponent {
* @param context the context
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context) {
- activateLocationComponent(context,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style) {
+ activateLocationComponent(context, style,
LocationComponentOptions.createFromAttributes(context, R.style.mapbox_LocationComponent));
}
@@ -215,11 +216,12 @@ public final class LocationComponent {
* there should be no location engine initialized
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, boolean useDefaultLocationEngine) {
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ boolean useDefaultLocationEngine) {
if (useDefaultLocationEngine) {
- activateLocationComponent(context, R.style.mapbox_LocationComponent);
+ activateLocationComponent(context, style, R.style.mapbox_LocationComponent);
} else {
- activateLocationComponent(context, null, R.style.mapbox_LocationComponent);
+ activateLocationComponent(context, style, null, R.style.mapbox_LocationComponent);
}
}
@@ -233,13 +235,14 @@ public final class LocationComponent {
* @param locationEngineRequest the location request
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, boolean useDefaultLocationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ boolean useDefaultLocationEngine,
@NonNull LocationEngineRequest locationEngineRequest) {
setLocationEngineRequest(locationEngineRequest);
if (useDefaultLocationEngine) {
- activateLocationComponent(context, R.style.mapbox_LocationComponent);
+ activateLocationComponent(context, style, R.style.mapbox_LocationComponent);
} else {
- activateLocationComponent(context, null, R.style.mapbox_LocationComponent);
+ activateLocationComponent(context, style, null, R.style.mapbox_LocationComponent);
}
}
@@ -253,8 +256,8 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @StyleRes int styleRes) {
- activateLocationComponent(context, LocationComponentOptions.createFromAttributes(context, styleRes));
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @StyleRes int styleRes) {
+ activateLocationComponent(context, style, LocationComponentOptions.createFromAttributes(context, styleRes));
}
/**
@@ -268,8 +271,9 @@ public final class LocationComponent {
* @param options the options
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @NonNull LocationComponentOptions options) {
- initialize(context, options);
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @NonNull LocationComponentOptions options) {
+ initialize(context, style, options);
initializeLocationEngine(context);
applyStyle(options);
}
@@ -283,9 +287,9 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
- @StyleRes int styleRes) {
- activateLocationComponent(context, locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @Nullable LocationEngine locationEngine, @StyleRes int styleRes) {
+ activateLocationComponent(context, style, locationEngine,
LocationComponentOptions.createFromAttributes(context, styleRes));
}
@@ -299,9 +303,10 @@ public final class LocationComponent {
* @param styleRes the LocationComponent style res
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @Nullable LocationEngine locationEngine,
@NonNull LocationEngineRequest locationEngineRequest, @StyleRes int styleRes) {
- activateLocationComponent(context, locationEngine, locationEngineRequest,
+ activateLocationComponent(context, style, locationEngine, locationEngineRequest,
LocationComponentOptions.createFromAttributes(context, styleRes));
}
@@ -312,8 +317,9 @@ public final class LocationComponent {
* @param locationEngine the engine
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @NonNull LocationEngine locationEngine) {
- activateLocationComponent(context, locationEngine, R.style.mapbox_LocationComponent);
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @NonNull LocationEngine locationEngine) {
+ activateLocationComponent(context, style, locationEngine, R.style.mapbox_LocationComponent);
}
/**
@@ -324,9 +330,10 @@ public final class LocationComponent {
* @param locationEngineRequest the location request
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @NonNull LocationEngine locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @NonNull LocationEngine locationEngine,
@NonNull LocationEngineRequest locationEngineRequest) {
- activateLocationComponent(context, locationEngine, locationEngineRequest, R.style.mapbox_LocationComponent);
+ activateLocationComponent(context, style, locationEngine, locationEngineRequest, R.style.mapbox_LocationComponent);
}
/**
@@ -337,9 +344,10 @@ public final class LocationComponent {
* @param options the options
*/
@RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
- public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @Nullable LocationEngine locationEngine,
@NonNull LocationComponentOptions options) {
- initialize(context, options);
+ initialize(context, style, options);
setLocationEngine(locationEngine);
applyStyle(options);
}
@@ -353,10 +361,11 @@ public final class LocationComponent {
* @param locationEngineRequest the location request
* @param options the options
*/
- public void activateLocationComponent(@NonNull Context context, @Nullable LocationEngine locationEngine,
+ public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
+ @Nullable LocationEngine locationEngine,
@NonNull LocationEngineRequest locationEngineRequest,
@NonNull LocationComponentOptions options) {
- initialize(context, options);
+ initialize(context, style, options);
setLocationEngineRequest(locationEngineRequest);
setLocationEngine(locationEngine);
applyStyle(options);
@@ -899,57 +908,45 @@ public final class LocationComponent {
mapboxMap.removeOnCameraIdleListener(onCameraIdleListener);
}
- private void initialize(@NonNull final Context context, @NonNull final LocationComponentOptions options) {
- LocationComponent.this.options = options;
- mapboxMap.getStyle(new InitializationCallback(context));
- }
-
- class InitializationCallback implements Style.OnStyleLoaded {
-
- private final Context context;
-
- private InitializationCallback(Context context) {
- this.context = context;
+ private void initialize(@NonNull final Context context, @NonNull Style style,
+ @NonNull final LocationComponentOptions options) {
+ if (isComponentInitialized) {
+ return;
}
+ isComponentInitialized = true;
- @Override
- public void onStyleLoaded(@NonNull Style style) {
- if (isComponentInitialized) {
- return;
- }
- isComponentInitialized = true;
-
- mapboxMap.addOnMapClickListener(onMapClickListener);
- mapboxMap.addOnMapLongClickListener(onMapLongClickListener);
-
- LayerSourceProvider sourceProvider = new LayerSourceProvider();
- LayerFeatureProvider featureProvider = new LayerFeatureProvider();
- LayerBitmapProvider bitmapProvider = new LayerBitmapProvider(context);
- locationLayerController = new LocationLayerController(mapboxMap, sourceProvider, featureProvider,
- bitmapProvider,
- options);
- locationCameraController = new LocationCameraController(
- context, mapboxMap, cameraTrackingChangedListener, options, onCameraMoveInvalidateListener);
-
- locationAnimatorCoordinator = new LocationAnimatorCoordinator();
- locationAnimatorCoordinator.addLayerListener(locationLayerController);
- locationAnimatorCoordinator.addCameraListener(locationCameraController);
- locationAnimatorCoordinator.setTrackingAnimationDurationMultiplier(options
- .trackingAnimationDurationMultiplier());
-
- WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
- compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
- compassEngine.addCompassListener(compassListener);
- staleStateManager = new StaleStateManager(onLocationStaleListener, options);
+ this.style = style;
+ this.options = options;
+
+ mapboxMap.addOnMapClickListener(onMapClickListener);
+ mapboxMap.addOnMapLongClickListener(onMapLongClickListener);
+
+ LayerSourceProvider sourceProvider = new LayerSourceProvider();
+ LayerFeatureProvider featureProvider = new LayerFeatureProvider();
+ LayerBitmapProvider bitmapProvider = new LayerBitmapProvider(context);
+ locationLayerController = new LocationLayerController(mapboxMap, style, sourceProvider, featureProvider,
+ bitmapProvider, options);
+ locationCameraController = new LocationCameraController(
+ context, mapboxMap, cameraTrackingChangedListener, options, onCameraMoveInvalidateListener);
+
+ locationAnimatorCoordinator = new LocationAnimatorCoordinator();
+ locationAnimatorCoordinator.addLayerListener(locationLayerController);
+ locationAnimatorCoordinator.addCameraListener(locationCameraController);
+ locationAnimatorCoordinator.setTrackingAnimationDurationMultiplier(options
+ .trackingAnimationDurationMultiplier());
+
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ compassEngine = new LocationComponentCompassEngine(windowManager, sensorManager);
+ compassEngine.addCompassListener(compassListener);
+ staleStateManager = new StaleStateManager(onLocationStaleListener, options);
- updateMapWithOptions(options);
+ updateMapWithOptions(options);
- setRenderMode(RenderMode.NORMAL);
- setCameraMode(CameraMode.NONE);
+ setRenderMode(RenderMode.NORMAL);
+ setCameraMode(CameraMode.NONE);
- onLocationLayerStart();
- }
+ onLocationLayerStart();
}
private void initializeLocationEngine(@NonNull Context context) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
index 0e7508ab74..ed15e52a08 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java
@@ -13,6 +13,7 @@ import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -61,6 +62,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
private int renderMode;
private final MapboxMap mapboxMap;
+ private final Style style;
private final LayerSourceProvider layerSourceProvider;
private final LayerBitmapProvider bitmapProvider;
private LocationComponentOptions options;
@@ -71,10 +73,11 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
private boolean isHidden = true;
- LocationLayerController(MapboxMap mapboxMap, LayerSourceProvider layerSourceProvider,
+ LocationLayerController(MapboxMap mapboxMap, Style style, LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider, LayerBitmapProvider bitmapProvider,
@NonNull LocationComponentOptions options) {
this.mapboxMap = mapboxMap;
+ this.style = style;
this.layerSourceProvider = layerSourceProvider;
this.bitmapProvider = bitmapProvider;
this.locationFeature = featureProvider.generateLocationFeature(locationFeature, options);
@@ -193,7 +196,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
}
private void setLayerVisibility(@NonNull String layerId, boolean visible) {
- Layer layer = mapboxMap.getStyle().getLayer(layerId);
+ Layer layer = style.getLayer(layerId);
if (layer != null) {
String targetVisibility = visible ? VISIBLE : NONE;
if (!layer.getVisibility().value.equals(targetVisibility)) {
@@ -221,7 +224,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
}
private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) {
- mapboxMap.getStyle().addLayerBelow(layer, idBelowLayer);
+ style.addLayerBelow(layer, idBelowLayer);
layerMap.add(layer.getId());
}
@@ -243,11 +246,11 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
private void addLocationSource() {
locationSource = layerSourceProvider.generateSource(locationFeature);
- mapboxMap.getStyle().addSource(locationSource);
+ style.addSource(locationSource);
}
private void refreshSource() {
- GeoJsonSource source = mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE);
+ GeoJsonSource source = style.getSourceAs(LOCATION_SOURCE);
if (source != null) {
locationSource.setGeoJson(locationFeature);
}
@@ -272,17 +275,17 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
Bitmap backgroundStaleBitmap = bitmapProvider.generateBitmap(
options.backgroundDrawableStale(), options.backgroundStaleTintColor()
);
- mapboxMap.getStyle().addImage(BACKGROUND_ICON, backgroundBitmap);
- mapboxMap.getStyle().addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
+ style.addImage(BACKGROUND_ICON, backgroundBitmap);
+ style.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
}
private void styleShadow(@NonNull LocationComponentOptions options) {
- mapboxMap.getStyle().addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
+ style.addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
}
private void styleBearing(LocationComponentOptions options) {
Bitmap bearingBitmap = bitmapProvider.generateBitmap(options.bearingDrawable(), options.bearingTintColor());
- mapboxMap.getStyle().addImage(BEARING_ICON, bearingBitmap);
+ style.addImage(BEARING_ICON, bearingBitmap);
}
private void styleAccuracy(float accuracyAlpha, @ColorInt int accuracyColor) {
@@ -306,13 +309,13 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
options.gpsDrawable(), options.foregroundStaleTintColor()
);
}
- mapboxMap.getStyle().addImage(FOREGROUND_ICON, foregroundBitmap);
- mapboxMap.getStyle().addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
+ style.addImage(FOREGROUND_ICON, foregroundBitmap);
+ style.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
}
private void styleScaling(@NonNull LocationComponentOptions options) {
for (String layerId : layerMap) {
- Layer layer = mapboxMap.getStyle().getLayer(layerId);
+ Layer layer = style.getLayer(layerId);
if (layer instanceof SymbolLayer) {
layer.setProperties(
iconSize(
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index 558ea56a0d..b4c977cf15 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -1061,7 +1061,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private class MapCallback implements OnDidFinishLoadingStyleListener,
OnDidFinishRenderingFrameListener, OnDidFinishLoadingMapListener,
- OnCameraIsChangingListener, OnCameraDidChangeListener {
+ OnCameraIsChangingListener, OnCameraDidChangeListener, OnDidFailLoadingMapListener {
private final List<OnMapReadyCallback> onMapReadyCallbackList = new ArrayList<>();
@@ -1071,6 +1071,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
addOnDidFinishLoadingMapListener(this);
addOnCameraIsChangingListener(this);
addOnCameraDidChangeListener(this);
+ addOnDidFailLoadingMapListener(this);
}
void initialised() {
@@ -1107,6 +1108,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
removeOnDidFinishLoadingMapListener(this);
removeOnCameraIsChangingListener(this);
removeOnCameraDidChangeListener(this);
+ removeOnDidFailLoadingMapListener(this);
}
@Override
@@ -1117,6 +1119,13 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
@Override
+ public void onDidFailLoadingMap(String errorMessage) {
+ if (mapboxMap != null) {
+ mapboxMap.onFailLoadingStyle();
+ }
+ }
+
+ @Override
public void onDidFinishRenderingFrame(boolean fully) {
if (mapboxMap != null) {
mapboxMap.onUpdateFullyRendered();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index bcc7037657..03fbdab3bd 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -5,6 +5,7 @@ import android.graphics.Bitmap;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Bundle;
+import android.os.Handler;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -197,13 +198,20 @@ public final class MapboxMap {
}
/**
- * Called the map finished loading style.
+ * Called when the map finished loading a style.
*/
void onFinishLoadingStyle() {
notifyStyleLoaded();
}
/**
+ * Called when the map failed loading a style.
+ */
+ void onFailLoadingStyle() {
+ styleLoadedCallbacks.clear();
+ }
+
+ /**
* Called when the region is changing or has changed.
*/
void onUpdateRegionChange() {
@@ -663,6 +671,7 @@ public final class MapboxMap {
* Loads a new style from the specified offline region definition and moves the map camera to that region.
*
* @param definition the offline region definition
+ * @param callback the callback to be invoked when the style has loaded
* @see OfflineRegionDefinition
*/
public void setOfflineRegionDefinition(@NonNull OfflineRegionDefinition definition,
@@ -812,7 +821,7 @@ public final class MapboxMap {
// user didn't provide a `from` component,
// flag the style as loaded,
// add components defined added using the `with` prefix.
- notifyStyleLoaded();
+ notifyStyleLoadedDelayed();
}
}
@@ -833,6 +842,15 @@ public final class MapboxMap {
styleLoadedCallbacks.clear();
}
+ private void notifyStyleLoadedDelayed() {
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ notifyStyleLoaded();
+ }
+ });
+ }
+
/**
* Loads a new map style from MapboxMapOptions if available.
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
index 5e2439cba3..72de0b24c5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
@@ -123,7 +123,7 @@ public class Style {
}
/**
- * Removes the source. Any references to the source become invalid and should not be used anymore
+ * Removes the source from the style.
*
* @param sourceId the source to remove
* @return the source handle or null if the source was not present
@@ -261,7 +261,6 @@ public class Style {
* @return the removed layer or null if not found
*/
public boolean removeLayerAt(@IntRange(from = 0) int index) {
- // TODO what about runtime added sources?
return nativeMapView.removeLayerAt(index);
}
@@ -366,6 +365,7 @@ public class Style {
* by setting the java sources and layers in a detached state and removing them from core.
*/
void onWillStartLoadingMap() {
+ styleLoaded = false;
for (Source source : sources.values()) {
if (source != null) {
source.setDetached();
@@ -451,7 +451,7 @@ public class Style {
* </p>
* {@code url} can take the following forms:
* <ul>
- * <li>{@code Style.*}: load one of the bundled styles in {@link Style}.</li>
+ * <li>{@code Style#StyleUrl}: load one of the bundled styles in {@link Style}.</li>
* <li>{@code mapbox://styles/<user>/<style>}:
* loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
* {@code user} is your username. {@code style} is the ID of your custom
@@ -461,12 +461,16 @@ public class Style {
* <li>{@code asset://...}:
* loads the style from the APK {@code assets/} directory.
* This is used to load a style bundled with your app.</li>
+ * <li>{@code file://...}:
+ * loads the style from a file path. This is used to load a style from disk.
+ * </li>
+ * </li>
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
* </ul>
* <p>
* This method is asynchronous and will return before the style finishes loading.
* If you wish to wait for the map to finish loading, listen to the {@link MapView.OnDidFinishLoadingStyleListener}
- * callback.
+ * callback or use {@link MapboxMap#setStyle(String, OnStyleLoaded)} instead.
* </p>
* If the style fails to load or an invalid style URL is set, the map view will become blank.
* An error message will be logged in the Android logcat and {@link MapView.OnDidFailLoadingMapListener} callback
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
index 853760f6df..b0bea5aa0e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
@@ -9,6 +9,7 @@ import com.mapbox.android.core.location.LocationEngineRequest
import com.mapbox.mapboxsdk.R
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
+import io.mockk.mockk
import org.junit.Assert
import org.junit.Before
import org.junit.Test
@@ -75,8 +76,7 @@ class LocationComponentTest {
@Test
fun activateWithRequestTest() {
- locationComponent.activateLocationComponent(context, locationEngine, locationEngineRequest, locationComponentOptions)
- verify(mapboxMap).getStyle(ArgumentMatchers.any(Style.OnStyleLoaded::class.java))
+ locationComponent.activateLocationComponent(context, mockk(), locationEngine, locationEngineRequest, locationComponentOptions)
Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
@@ -90,13 +90,13 @@ class LocationComponentTest {
.getDimension(R.dimen.mapbox_locationComponentTrackingMultiFingerMoveThreshold)
doReturn(0f).`when`(resources)
.getDimension(R.dimen.mapbox_locationComponentTrackingMultiFingerMoveThreshold)
- locationComponent.activateLocationComponent(context, true, locationEngineRequest)
+ locationComponent.activateLocationComponent(context, mockk(),true, locationEngineRequest)
Assert.assertEquals(locationEngineRequest, locationComponent.locationEngineRequest)
}
@Test
fun locationUpdatesWhenEnabledDisableTest() {
- locationComponent.activateLocationComponent(context, locationEngine, locationEngineRequest, locationComponentOptions)
+ locationComponent.activateLocationComponent(context, mockk(), locationEngine, locationEngineRequest, locationComponentOptions)
verify(locationEngine, times(0)).removeLocationUpdates(currentListener)
verify(locationEngine, times(0)).requestLocationUpdates(eq(locationEngineRequest), eq(currentListener), any(Looper::class.java))
@@ -114,7 +114,7 @@ class LocationComponentTest {
@Test
fun locationUpdatesWhenStartedStoppedTest() {
- locationComponent.activateLocationComponent(context, locationEngine, locationEngineRequest, locationComponentOptions)
+ locationComponent.activateLocationComponent(context, mockk(), locationEngine, locationEngineRequest, locationComponentOptions)
locationComponent.onStart()
locationComponent.isLocationComponentEnabled = true
@@ -127,7 +127,7 @@ class LocationComponentTest {
@Test
fun locationUpdatesWhenNewRequestTest() {
- locationComponent.activateLocationComponent(context, locationEngine, locationEngineRequest, locationComponentOptions)
+ locationComponent.activateLocationComponent(context, mockk(), locationEngine, locationEngineRequest, locationComponentOptions)
locationComponent.onStart()
locationComponent.isLocationComponentEnabled = true
@@ -139,7 +139,7 @@ class LocationComponentTest {
@Test
fun lastLocationUpdateOnStartTest() {
- locationComponent.activateLocationComponent(context, locationEngine, locationEngineRequest, locationComponentOptions)
+ locationComponent.activateLocationComponent(context, mockk(), locationEngine, locationEngineRequest, locationComponentOptions)
locationComponent.onStart()
locationComponent.isLocationComponentEnabled = true
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
index 475fb81684..68e31275f1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
@@ -56,7 +56,8 @@ public class LocationLayerControllerTest {
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addSource(locationSource);
}
@@ -71,7 +72,8 @@ public class LocationLayerControllerTest {
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addLayerBelow(shadowLayer, BACKGROUND_LAYER);
}
@@ -86,7 +88,8 @@ public class LocationLayerControllerTest {
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addLayerBelow(backgroundLayer, FOREGROUND_LAYER);
}
@@ -101,7 +104,8 @@ public class LocationLayerControllerTest {
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addLayerBelow(foregroundLayer, BEARING_LAYER);
}
@@ -118,7 +122,8 @@ public class LocationLayerControllerTest {
String layerBelow = "layer-below";
when(options.layerBelow()).thenReturn(layerBelow);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addLayerBelow(bearingLayer, layerBelow);
}
@@ -133,7 +138,8 @@ public class LocationLayerControllerTest {
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
}
@@ -149,7 +155,8 @@ public class LocationLayerControllerTest {
when(options.elevation()).thenReturn(2f);
// Style is applied on initialization
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(SHADOW_ICON, bitmap);
}
@@ -164,7 +171,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
when(options.elevation()).thenReturn(0f);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style, times(0)).addImage(SHADOW_ICON, bitmap);
}
@@ -182,7 +190,8 @@ public class LocationLayerControllerTest {
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(FOREGROUND_ICON, bitmap);
}
@@ -200,7 +209,8 @@ public class LocationLayerControllerTest {
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(FOREGROUND_STALE_ICON, bitmap);
}
@@ -218,7 +228,8 @@ public class LocationLayerControllerTest {
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(BACKGROUND_ICON, bitmap);
}
@@ -236,7 +247,8 @@ public class LocationLayerControllerTest {
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(BACKGROUND_STALE_ICON, bitmap);
}
@@ -254,7 +266,8 @@ public class LocationLayerControllerTest {
Bitmap bitmap = mock(Bitmap.class);
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
- new LocationLayerController(mapboxMap, sourceProvider, buildFeatureProvider(options), bitmapProvider, options);
+ new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
+ bitmapProvider, options);
verify(style).addImage(BEARING_ICON, bitmap);
}
@@ -268,7 +281,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.updateForegroundOffset(2d);
@@ -285,7 +299,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.updateForegroundOffset(2d);
@@ -302,7 +317,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.onNewLatLngValue(new LatLng());
@@ -320,7 +336,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.setRenderMode(RenderMode.GPS);
float gpsBearing = 2f;
@@ -340,7 +357,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.setRenderMode(RenderMode.COMPASS);
float gpsBearing = 2f;
@@ -360,7 +378,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.setRenderMode(RenderMode.COMPASS);
float compassBearing = 2f;
@@ -380,7 +399,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.setRenderMode(RenderMode.GPS);
float compassBearing = 2f;
@@ -400,7 +420,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
float accuracyRadiusValue = 2f;
@@ -419,7 +440,8 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
- mapboxMap, sourceProvider, buildFeatureProvider(locationFeature, options), bitmapProvider, options
+ mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
+ bitmapProvider, options
);
layer.setRenderMode(RenderMode.GPS);
float accuracyRadiusValue = 2f;
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
index 0c9abc82ba..4b2f3e287e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/StyleTest.kt
@@ -9,6 +9,7 @@ import io.mockk.every
import io.mockk.mockk
import io.mockk.spyk
import io.mockk.verify
+import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -273,4 +274,34 @@ class StyleTest {
verify(exactly = 1) { nativeMapView.addSource(source) }
verify(exactly = 1) { callback.onStyleLoaded(any()) }
}
+
+ @Test
+ fun testGetNullStyle() {
+ Assert.assertNull(mapboxMap.style)
+ }
+
+ @Test
+ fun testGetNullWhileLoading() {
+ val transitionOptions = TransitionOptions(100, 200)
+ val builder = Style.Builder().fromUrl(Style.MAPBOX_STREETS).withTransition(transitionOptions)
+ mapboxMap.setStyle(builder)
+ Assert.assertNull(mapboxMap.style)
+ mapboxMap.notifyStyleLoaded()
+ Assert.assertNotNull(mapboxMap.style)
+ }
+
+ @Test
+ fun testNotReinvokeSameListener() {
+ val callback = mockk<Style.OnStyleLoaded>()
+ every { callback.onStyleLoaded(any()) } answers {}
+ mapboxMap.getStyle(callback)
+ val source = mockk<GeoJsonSource>()
+ every { source.id } returns "1"
+ val builder = Style.Builder().fromJson("{}")
+ mapboxMap.setStyle(builder)
+ verify(exactly = 1) { nativeMapView.styleJson = "{}" }
+ mapboxMap.notifyStyleLoaded()
+ mapboxMap.setStyle(Style.MAPBOX_STREETS)
+ verify(exactly = 1) { callback.onStyleLoaded(any()) }
+ }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
index 9f756239e1..8362095042 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationComponentTest.kt
@@ -75,7 +75,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context)
+ component.activateLocationComponent(context, mapboxMap.style!!)
component.isLocationComponentEnabled = true
val locationEngine = component.locationEngine
@@ -96,6 +96,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(
context,
+ mapboxMap.style!!,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
.enableStaleState(false)
@@ -127,6 +128,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(
context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -158,8 +160,9 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
+ val style = mapboxMap.style!!
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, style,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -181,7 +184,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
// Source should be present but empty
@@ -212,6 +215,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -223,6 +227,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
uiController.loopMainThreadForAtLeast(500)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also {
it.forEach {
assertThat(it.getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
@@ -241,6 +246,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -264,6 +270,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
assertThat(mapboxMap.queryRenderedFeatures(location, FOREGROUND_LAYER).isEmpty(), `is`(false))
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val feature = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0]
assertThat(feature.getStringProperty(PROPERTY_FOREGROUND_ICON), `is`(equalTo("custom-foreground-bitmap")))
assertThat(feature.getStringProperty(PROPERTY_BACKGROUND_ICON), `is`(equalTo("custom-background-bitmap")))
@@ -283,6 +290,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -298,7 +306,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.addImageFromDrawable("custom-foreground-bitmap", it)
mapboxMap.addImageFromDrawable("custom-gps-bitmap", it)
}
-
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
}
@@ -314,6 +322,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.foregroundName("custom-foreground-bitmap")
@@ -325,12 +334,14 @@ class LocationComponentTest : BaseActivityTest() {
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.applyStyle(LocationComponentOptions.builder(context).build())
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) == FOREGROUND_ICON
}
waitForRenderResult(uiController, renderCheck, true)
@@ -349,6 +360,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.gpsName("custom-gps-bitmap")
@@ -359,12 +371,14 @@ class LocationComponentTest : BaseActivityTest() {
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val foregroundId = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON)
assertThat(foregroundId, `is`(equalTo("custom-gps-bitmap")))
component.renderMode = RenderMode.NORMAL
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getStringProperty(PROPERTY_FOREGROUND_ICON) == FOREGROUND_ICON
}
waitForRenderResult(uiController, renderCheck, true)
@@ -382,6 +396,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.staleStateTimeout(200)
@@ -393,6 +408,7 @@ class LocationComponentTest : BaseActivityTest() {
uiController.loopMainThreadForAtLeast(250) // engaging stale state
val renderCheck = {
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE)
}
waitForRenderResult(uiController, renderCheck, true)
@@ -402,6 +418,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(true))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(false))
}
@@ -416,16 +433,19 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
component.onStop()
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getBooleanProperty(PROPERTY_LOCATION_STALE), `is`(false))
assertThat(mapboxMap.isLayerVisible(ACCURACY_LAYER), `is`(true))
}
@@ -443,6 +463,7 @@ class LocationComponentTest : BaseActivityTest() {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
component.activateLocationComponent(context,
+ mapboxMap.style!!,
null,
LocationComponentOptions.builder(context)
.accuracyColor(color)
@@ -453,6 +474,7 @@ class LocationComponentTest : BaseActivityTest() {
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
// Check that the source property changes correctly
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
mapboxMap.querySourceFeatures(LOCATION_SOURCE).also {
it.forEach {
assertThat(it.getStringProperty(PROPERTY_ACCURACY_COLOR), `is`(equalTo(rgbaColor)))
@@ -470,11 +492,12 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertThat(component.locationEngine, nullValue())
@@ -491,7 +514,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -514,7 +537,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -540,7 +563,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStop()
component.onStart()
assertThat(component.isLocationComponentEnabled, `is`(false))
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertThat(component.isLocationComponentEnabled, `is`(true))
}
@@ -554,7 +577,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertThat(component.isLocationComponentEnabled, `is`(true))
component.onStop()
@@ -571,7 +594,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.isLocationComponentEnabled = false
assertThat(component.isLocationComponentEnabled, `is`(false))
@@ -589,7 +612,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.onStop()
@@ -608,7 +631,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
component.onStop()
@@ -625,12 +648,13 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.onStop()
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertThat(mapboxMap.querySourceFeatures(LOCATION_SOURCE).isEmpty(), `is`(true))
}
}
@@ -643,13 +667,15 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.onStop()
component.forceLocationUpdate(location)
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
assertEquals(point.longitude(), location.longitude, 0.1)
@@ -664,7 +690,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
@@ -673,6 +699,7 @@ class LocationComponentTest : BaseActivityTest() {
component.onStart()
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
val point: Point = mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].geometry() as Point
assertEquals(point.latitude(), location.latitude, 0.1)
assertEquals(point.longitude(), location.longitude, 0.1)
@@ -693,9 +720,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
val options = LocationComponentOptions.builder(context)
.accuracyColor(Color.RED)
.build()
@@ -719,9 +746,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
pushSourceUpdates(styleChangeIdlingResource) {
component.forceLocationUpdate(location)
@@ -742,8 +769,9 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
- component.activateLocationComponent(context, false)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
+ uiController.loopMainThreadForAtLeast(100)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
val options = LocationComponentOptions.builder(context)
@@ -768,7 +796,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.GPS
location.bearing = 77f
@@ -776,11 +804,15 @@ class LocationComponentTest : BaseActivityTest() {
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY)
assertThat(mapboxMap.style, notNullValue())
assertThat(mapboxMap.style?.getSource(LOCATION_SOURCE), notNullValue())
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
assertEquals(77.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1)
location.bearing = 92f
component.forceLocationUpdate(location)
uiController.loopMainThreadForAtLeast(MAX_ANIMATION_DURATION_MS + MAP_RENDER_DELAY) // Waiting for the animation to finish
+ mapboxMap.waitForSource(uiController, LOCATION_SOURCE)
+ mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
assertEquals(92.0, mapboxMap.querySourceFeatures(LOCATION_SOURCE)[0].getNumberProperty(PROPERTY_GPS_BEARING) as Double, 0.1)
}
}
@@ -793,7 +825,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING_GPS
location.bearing = 77f
@@ -822,7 +854,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE_GPS
val latitude = mapboxMap.cameraPosition.target.latitude
@@ -854,7 +886,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val latitude = mapboxMap.cameraPosition.target.latitude
@@ -887,7 +919,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.cameraMode = CameraMode.NONE
@@ -906,7 +938,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val zoom = mapboxMap.cameraPosition.zoom
@@ -925,7 +957,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(10.0)
@@ -944,7 +976,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(15.0)
@@ -964,7 +996,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
@@ -987,7 +1019,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.zoomWhileTracking(15.0)
@@ -1007,7 +1039,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.NONE
val tilt = mapboxMap.cameraPosition.tilt
@@ -1026,7 +1058,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1045,7 +1077,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1065,7 +1097,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
val tilt = mapboxMap.cameraPosition.tilt
@@ -1087,7 +1119,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING
component.tiltWhileTracking(30.0)
@@ -1107,7 +1139,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.cameraMode = CameraMode.TRACKING_GPS
component.forceLocationUpdate(location)
@@ -1131,7 +1163,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
val target = LatLng(51.0, 17.0)
assertTrue(target.distanceTo(LatLng(location)) > LocationComponentConstants.INSTANT_LOCATION_TRANSITION_THRESHOLD)
@@ -1154,7 +1186,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
assertTrue(component.compassEngine is LocationComponentCompassEngine)
}
@@ -1168,7 +1200,7 @@ class LocationComponentTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
val engine: CompassEngine = object : CompassEngine {
override fun addCompassListener(compassListener: CompassListener) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
index b8f146f983..12ae701d0a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -75,7 +75,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
@@ -94,7 +94,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -114,7 +114,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.COMPASS
component.forceLocationUpdate(location)
@@ -134,7 +134,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.GPS
component.forceLocationUpdate(location)
@@ -154,7 +154,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -183,7 +183,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -207,7 +207,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
@@ -239,7 +239,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(100).build())
component.forceLocationUpdate(location)
@@ -268,10 +268,10 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
component.applyStyle(LocationComponentOptions.builder(context).staleStateTimeout(1).build())
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
pushSourceUpdates(styleChangeIdlingResource) {
component.forceLocationUpdate(location)
}
@@ -288,9 +288,10 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- styleChangeIdlingResource.waitForStyle((rule.activity as SingleActivity).mapView, mapboxMap, MAPBOX_HEAVY_STYLE)
+ styleChangeIdlingResource.waitForStyle(mapboxMap, MAPBOX_HEAVY_STYLE)
+ uiController.loopMainThreadForAtLeast(100)
var show = true
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
pushSourceUpdates(styleChangeIdlingResource) {
component.isLocationComponentEnabled = show
show = !show
@@ -310,7 +311,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!,false)
component.isLocationComponentEnabled = true
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(location), 16.0))
component.forceLocationUpdate(location)
@@ -330,7 +331,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
@@ -364,7 +365,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
val componentAction = object : LocationComponentAction.OnPerformLocationComponentAction {
override fun onLocationComponentAction(component: LocationComponent, mapboxMap: MapboxMap,
uiController: UiController, context: Context) {
- component.activateLocationComponent(context, false)
+ component.activateLocationComponent(context, mapboxMap.style!!, false)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.waitForLayer(uiController, location, FOREGROUND_LAYER)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
index 55ad7179ec..5aded25d1e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/StyleChangeIdlingResource.kt
@@ -1,9 +1,9 @@
package com.mapbox.mapboxsdk.location.utils
import android.support.test.espresso.IdlingResource
-import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style
+import java.util.logging.Handler
/**
* Resource, that's idling until the provided style is loaded.
@@ -32,14 +32,10 @@ class StyleChangeIdlingResource : IdlingResource {
callback?.onTransitionToIdle()
}
- fun waitForStyle(mapView: MapView, mapboxMap: MapboxMap, styleUrl: String) {
+ fun waitForStyle(mapboxMap: MapboxMap, styleUrl: String) {
isIdle = false
- mapView.addOnDidFinishLoadingStyleListener(object : MapView.OnDidFinishLoadingStyleListener {
- override fun onDidFinishLoadingStyle() {
- mapView.removeOnDidFinishLoadingStyleListener(this)
- setIdle()
- }
- })
- mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl))
+ mapboxMap.setStyle(Style.Builder().fromUrl(styleUrl)) {
+ setIdle()
+ }
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
new file mode 100644
index 0000000000..1f9acbb291
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/StyleLoadTest.kt
@@ -0,0 +1,45 @@
+package com.mapbox.mapboxsdk.testapp.maps
+
+import android.support.test.espresso.UiController
+import android.support.test.runner.AndroidJUnit4
+import com.mapbox.mapboxsdk.maps.MapView
+import com.mapbox.mapboxsdk.maps.MapboxMap
+import com.mapbox.mapboxsdk.maps.Style
+import com.mapbox.mapboxsdk.style.layers.SymbolLayer
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
+import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction
+import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest
+import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class StyleLoadTest : BaseActivityTest() {
+
+ private lateinit var mapView: MapView
+
+ override fun getActivityClass(): Class<*> {
+ return EspressoTestActivity::class.java
+ }
+
+ @Before
+ override fun beforeTest() {
+ super.beforeTest()
+ mapView = (rule.activity as EspressoTestActivity).mapView
+ }
+
+ @Test
+ fun updateSourceAfterStyleLoad() {
+ validateTestSetup()
+ MapboxMapAction.invoke(mapboxMap) { uiController: UiController, mapboxMap: MapboxMap ->
+ val source = GeoJsonSource("id")
+ val layer = SymbolLayer("id", "id")
+ mapboxMap.setStyle(Style.Builder().withSource(source).withLayer(layer))
+ uiController.loopMainThreadForAtLeast(100)
+ mapboxMap.setStyle(Style.Builder().fromUrl(Style.MAPBOX_STREETS))
+ uiController.loopMainThreadForAtLeast(100)
+ source.setGeoJson("{}")
+ }
+ }
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
index caa15d05be..1bcab3932e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/utils/OnMapReadyIdlingResource.java
@@ -3,19 +3,14 @@ package com.mapbox.mapboxsdk.testapp.utils;
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
-import android.support.annotation.NonNull;
import android.support.annotation.WorkerThread;
import android.support.test.espresso.IdlingResource;
-
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
-import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.testapp.R;
-import junit.framework.Assert;
-
-public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallback {
+public class OnMapReadyIdlingResource implements IdlingResource {
private boolean styleLoaded;
private MapboxMap mapboxMap;
@@ -61,10 +56,4 @@ public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallb
public MapboxMap getMapboxMap() {
return mapboxMap;
}
-
- @Override
- public void onMapReady(@NonNull MapboxMap mapboxMap) {
- Assert.assertNotNull("MapboxMap should not be null", mapboxMap);
- this.mapboxMap = mapboxMap;
- }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
index f230872496..d55a4f5fde 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationFragmentActivity.kt
@@ -93,7 +93,6 @@ class LocationFragmentActivity : AppCompatActivity() {
private lateinit var mapView: MapView
private lateinit var mapboxMap: MapboxMap
- private var component: LocationComponent? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mapView = MapView(inflater.context)
@@ -105,11 +104,11 @@ class LocationFragmentActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync {
mapboxMap = it
- it.setStyle(Style.MAPBOX_STREETS) { _ ->
- component = mapboxMap.locationComponent
- component?.activateLocationComponent(activity)
- component?.isLocationComponentEnabled = true
- component?.locationEngine?.getLastLocation(this)
+ it.setStyle(Style.MAPBOX_STREETS) { style ->
+ val component = mapboxMap.locationComponent
+ component.activateLocationComponent(activity, style)
+ component.isLocationComponentEnabled = true
+ component.locationEngine?.getLastLocation(this)
}
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java
index df8617aa1b..7937f94ecc 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationMapChangeActivity.java
@@ -74,14 +74,14 @@ public class LocationMapChangeActivity extends AppCompatActivity implements OnMa
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(new Style.Builder().fromUrl(Utils.getNextStyle()),
- style -> activateLocationComponent());
+ style -> activateLocationComponent(style));
}
@SuppressLint("MissingPermission")
- private void activateLocationComponent() {
+ private void activateLocationComponent(@NonNull Style style) {
LocationComponent locationComponent = mapboxMap.getLocationComponent();
locationComponent.onStart();
- locationComponent.activateLocationComponent(this);
+ locationComponent.activateLocationComponent(this, style);
locationComponent.setLocationComponentEnabled(true);
locationComponent.setRenderMode(RenderMode.COMPASS);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
index 4abf68fc19..a00a0784ca 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/LocationModesActivity.java
@@ -137,7 +137,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
.build();
locationComponent = mapboxMap.getLocationComponent();
- locationComponent.activateLocationComponent(this, true,
+ locationComponent.activateLocationComponent(this, style, true,
new LocationEngineRequest.Builder(750)
.setFastestInterval(750)
.setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY)
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java
index 8b257371b6..dc6bf8a8b7 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/location/ManualLocationUpdatesActivity.java
@@ -111,6 +111,7 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(
this,
+ style,
locationEngine,
new LocationEngineRequest.Builder(500)
.setFastestInterval(500)