summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-11-08 14:11:12 +0100
committerTobrun <tobrun@mapbox.com>2018-12-10 19:09:07 +0100
commit70064d7f03257c11863afc46832015afbf30311e (patch)
treeae09a3509320537cefc5ea4b8bad6d8a031da2e2
parent437355f7bb9f35c740f759b7e1d4d8f785ba9b2c (diff)
downloadqtlocation-mapboxgl-70064d7f03257c11863afc46832015afbf30311e.tar.gz
[android] - remove style loaded listener
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java79
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java3
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java13
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java4
7 files changed, 26 insertions, 85 deletions
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 489ff62df5..8e76d14fc3 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
@@ -168,7 +168,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
// MapboxMap
mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, proj, registerTouchListener,
- annotationManager, cameraChangeDispatcher, mapChangeReceiver);
+ annotationManager, cameraChangeDispatcher);
// user input
mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings,
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 c0c870c2c3..6d68302c61 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
@@ -61,7 +61,6 @@ public final class MapboxMap {
private final Transform transform;
private final AnnotationManager annotationManager;
private final CameraChangeDispatcher cameraChangeDispatcher;
- private final MapChangeReceiver mapChangeReceiver;
private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener;
@@ -73,7 +72,7 @@ public final class MapboxMap {
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection,
OnGesturesManagerInteractionListener listener, AnnotationManager annotations,
- CameraChangeDispatcher cameraChangeDispatcher, MapChangeReceiver mapChangeReceiver) {
+ CameraChangeDispatcher cameraChangeDispatcher) {
this.nativeMapView = map;
this.style = new Style(nativeMapView);
this.uiSettings = ui;
@@ -82,7 +81,6 @@ public final class MapboxMap {
this.transform = transform;
this.onGesturesManagerInteractionListener = listener;
this.cameraChangeDispatcher = cameraChangeDispatcher;
- this.mapChangeReceiver = mapChangeReceiver;
}
void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
@@ -702,7 +700,7 @@ public final class MapboxMap {
* <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 or use the {@link #setStyleUrl(String, OnStyleLoadedListener)} method instead.
+ * callback.
* </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
@@ -712,47 +710,6 @@ public final class MapboxMap {
* @see Style
*/
public void setStyleUrl(@NonNull String url) {
- setStyleUrl(url, null);
- }
-
- /**
- * <p>
- * Loads a new map style asynchronous from the specified URL.
- * </p>
- * {@code url} can take the following forms:
- * <ul>
- * <li>{@code Style.*}: 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
- * style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
- * <li>{@code http://...} or {@code https://...}:
- * loads the style over the Internet from any web server.</li>
- * <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 null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
- * </ul>
- * <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
- * will be triggered.
- * <p>
- *
- * @param url The URL of the map style
- * @param callback The callback that is invoked when the style has loaded.
- * @see Style
- */
- public void setStyleUrl(@NonNull final String url, @Nullable final OnStyleLoadedListener callback) {
- if (callback != null) {
- mapChangeReceiver.addOnDidFinishLoadingStyleListener(new MapView.OnDidFinishLoadingStyleListener() {
- @Override
- public void onDidFinishLoadingStyle() {
- callback.onStyleLoaded(url);
- mapChangeReceiver.removeOnDidFinishLoadingStyleListener(this);
- }
- });
- }
nativeMapView.setStyleUrl(url);
}
@@ -763,7 +720,7 @@ public final class MapboxMap {
* <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 or use the {@link #setStyle(String, OnStyleLoadedListener)} method instead.
+ * callback.
* </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
@@ -777,22 +734,6 @@ public final class MapboxMap {
}
/**
- * <p>
- * Loads a new map style from the specified bundled style.
- * </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
- * will be triggered.
- *
- * @param style The bundled style.
- * @param callback The callback to be invoked when the style has finished loading
- * @see Style
- */
- public void setStyle(@NonNull @Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) {
- setStyleUrl(style, callback);
- }
-
- /**
* Loads a new map style from MapboxMapOptions if available.
*
* @param options the object containing the style url
@@ -800,7 +741,7 @@ public final class MapboxMap {
private void setStyleUrl(@NonNull MapboxMapOptions options) {
String style = options.getStyleUrl();
if (!TextUtils.isEmpty(style)) {
- setStyleUrl(style, null);
+ setStyleUrl(style);
}
}
@@ -2178,18 +2119,6 @@ public final class MapboxMap {
void onSnapshotReady(@NonNull Bitmap snapshot);
}
- /**
- * Interface definition for a callback to be invoked when the style has finished loading.
- */
- public interface OnStyleLoadedListener {
- /**
- * Invoked when the style has finished loading
- *
- * @param style the style that has been loaded
- */
- void onStyleLoaded(@NonNull String style);
- }
-
//
// Used for instrumentation testing
//
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
index 9ad1e1fc37..b1e31709c5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
@@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.style.layers.Property
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource
fun MapboxMap.querySourceFeatures(sourceId: String): List<Feature> {
- return this.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
+ return this.style.getSourceAs<GeoJsonSource>(sourceId)?.querySourceFeatures(null) ?: emptyList()
}
fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<Feature> {
@@ -25,7 +25,7 @@ fun MapboxMap.queryRenderedFeatures(location: Location, layerId: String): List<F
}
fun MapboxMap.isLayerVisible(layerId: String): Boolean {
- return this.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
+ return this.style.getLayer(layerId)?.visibility?.value?.equals(Property.VISIBLE)!!
}
fun MapboxMap.waitForSource(uiController: UiController, sourceId: String) {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
index eeabf38809..5ce63e321c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java
@@ -25,7 +25,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
@Override
public boolean onMapClick(@NonNull LatLng point) {
if (mapboxMap != null) {
- mapboxMap.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style));
+ mapboxMap.setStyle(Style.OUTDOORS);
}
return true;
}
@@ -39,6 +39,10 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
+
+ mapView.addOnDidFinishLoadingStyleListener(() -> {
+ Timber.d("Style Loaded");
+ });
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
index 5f90244ff4..79a7ebf98e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
@@ -93,6 +93,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
mapView.setStyleUrl(STYLES[currentStyleIndex]);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
+ mapView.addOnDidFinishLoadingStyleListener(() -> Timber.d("Style loaded"));
}
@Override
@@ -160,7 +161,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
if (currentStyleIndex == STYLES.length) {
currentStyleIndex = 0;
}
- mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
+ mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
index 59b5ee99aa..50be29cfb3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
@@ -79,6 +79,14 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
initFloatingActionButtons();
isLoadingStyle = false;
});
+
+ mapView.addOnDidFinishLoadingStyleListener(new MapView.OnDidFinishLoadingStyleListener() {
+ @Override
+ public void onDidFinishLoadingStyle() {
+ addBusStop();
+ isLoadingStyle = false;
+ }
+ });
}
private void addBusStopSource() {
@@ -211,10 +219,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
}
private void loadNewStyle() {
- mapboxMap.setStyleUrl(getNextStyle(), style -> {
- addBusStop();
- isLoadingStyle = false;
- });
+ mapboxMap.setStyleUrl(getNextStyle());
}
private void addBusStop() {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
index faa04c2e9b..d00fcbccba 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
@@ -152,6 +152,8 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
}
private void setupStyleChangeView() {
+ mapView.addOnDidFinishLoadingStyleListener(() -> Timber.d("Style loaded"));
+
FloatingActionButton fabStyles = findViewById(R.id.fabStyles);
fabStyles.setOnClickListener(view -> {
if (mapboxMap != null) {
@@ -159,7 +161,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
if (currentStyleIndex == STYLES.length) {
currentStyleIndex = 0;
}
- mapboxMap.setStyleUrl(STYLES[currentStyleIndex], style -> Timber.d("Style loaded %s", style));
+ mapboxMap.setStyleUrl(STYLES[currentStyleIndex]);
}
});
}