summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2018-10-31 15:50:11 +0100
committerTobrun <tobrun@mapbox.com>2018-11-01 22:57:10 +0100
commit7882ce127492495e1e78a080767814b7a70f4da3 (patch)
treed4ef941a762ff1151a31cff436a014add5f87dd9
parent37a4967149a8ff8aca38e3adf56dfa4aa6971798 (diff)
downloadqtlocation-mapboxgl-7882ce127492495e1e78a080767814b7a70f4da3.tar.gz
[android] - remove deprecation notices and code
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/ModuleProviderImpl.java5
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java55
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java51
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java64
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java30
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java175
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Telemetry.java61
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java16
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java92
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java5
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java23
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java56
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java55
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java46
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java32
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java16
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java38
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java44
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IdleZoomListener.java25
21 files changed, 234 insertions, 681 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/ModuleProviderImpl.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/ModuleProviderImpl.java
index 4f36f2b888..c64e91767c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/ModuleProviderImpl.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/ModuleProviderImpl.java
@@ -18,9 +18,6 @@ public class ModuleProviderImpl implements ModuleProvider {
@Override
@Nullable
public TelemetryDefinition obtainTelemetry() {
- // TODO remove singleton with next major release,
- // this is needed to make static methods on TelemetryImpl
- // backwards compatible without breaking semver
- return TelemetryImpl.getInstance();
+ return new TelemetryImpl();
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java
deleted file mode 100644
index 2b85555cc7..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/http/HttpRequestUtil.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.mapbox.mapboxsdk.http;
-
-import okhttp3.OkHttpClient;
-
-/**
- * Utility class for setting HttpRequest configurations.
- *
- * @deprecated use {@link com.mapbox.mapboxsdk.module.http.HttpRequestUtil} instead
- */
-@Deprecated
-public class HttpRequestUtil {
-
- /**
- * Set the log state of HttpRequest. Default value is true.
- * <p>
- * This configuration will outlast the lifecycle of the Map.
- * </p>
- *
- * @param enabled True will enable logging, false will disable
- * @deprecated use {@link com.mapbox.mapboxsdk.module.http.HttpRequestUtil#setLogEnabled(boolean)} instead
- */
- @Deprecated
- public static void setLogEnabled(boolean enabled) {
- com.mapbox.mapboxsdk.module.http.HttpRequestUtil.setLogEnabled(enabled);
- }
-
- /**
- * Enable printing of the request url when an error occurred. Default value is false.
- * <p>
- * Requires {@link #setLogEnabled(boolean)} to be activated.
- * </p>
- * <p>
- * This configuration will outlast the lifecycle of the Map.
- * </p>
- *
- * @param enabled True will print urls, false will disable
- * @deprecated use {@link com.mapbox.mapboxsdk.module.http.HttpRequestUtil#setPrintRequestUrlOnFailure(boolean)}
- * instead
- */
- @Deprecated
- public static void setPrintRequestUrlOnFailure(boolean enabled) {
- com.mapbox.mapboxsdk.module.http.HttpRequestUtil.setPrintRequestUrlOnFailure(enabled);
- }
-
- /**
- * Set the OkHttpClient used for requesting map resources.
- *
- * @param client the OkHttpClient
- * @deprecated use {@link com.mapbox.mapboxsdk.module.http.HttpRequestUtil#setOkHttpClient(OkHttpClient)} instead.
- */
- @Deprecated
- public static void setOkHttpClient(OkHttpClient client) {
- com.mapbox.mapboxsdk.module.http.HttpRequestUtil.setOkHttpClient(client);
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
index a87a290fd7..e5b8722ca8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
@@ -31,11 +31,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
private final CopyOnWriteArrayList<OnCameraMoveListener> onCameraMove = new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<OnCameraIdleListener> onCameraIdle = new CopyOnWriteArrayList<>();
- private OnCameraMoveStartedListener onCameraMoveStartedListener;
- private OnCameraMoveCanceledListener onCameraMoveCanceledListener;
- private OnCameraMoveListener onCameraMoveListener;
- private OnCameraIdleListener onCameraIdleListener;
-
@Retention(SOURCE)
@IntDef( {MOVE_STARTED, MOVE, MOVE_CANCELED, IDLE})
@interface CameraChange {
@@ -67,26 +62,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
handler.scheduleMessage(IDLE);
}
- @Deprecated
- void setOnCameraMoveStartedListener(OnCameraMoveStartedListener onCameraMoveStartedListener) {
- this.onCameraMoveStartedListener = onCameraMoveStartedListener;
- }
-
- @Deprecated
- void setOnCameraMoveCanceledListener(OnCameraMoveCanceledListener onCameraMoveCanceledListener) {
- this.onCameraMoveCanceledListener = onCameraMoveCanceledListener;
- }
-
- @Deprecated
- void setOnCameraMoveListener(OnCameraMoveListener onCameraMoveListener) {
- this.onCameraMoveListener = onCameraMoveListener;
- }
-
- @Deprecated
- void setOnCameraIdleListener(OnCameraIdleListener onCameraIdleListener) {
- this.onCameraIdleListener = onCameraIdleListener;
- }
-
void addOnCameraIdleListener(@NonNull OnCameraIdleListener listener) {
onCameraIdle.add(listener);
}
@@ -132,13 +107,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
return;
}
idle = false;
-
- // deprecated API
- if (onCameraMoveStartedListener != null) {
- onCameraMoveStartedListener.onCameraMoveStarted(moveStartedReason);
- }
-
- // new API
if (!onCameraMoveStarted.isEmpty()) {
for (OnCameraMoveStartedListener cameraMoveStartedListener : onCameraMoveStarted) {
cameraMoveStartedListener.onCameraMoveStarted(moveStartedReason);
@@ -147,12 +115,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
}
private void executeOnCameraMove() {
- // deprecated API
- if (onCameraMoveListener != null && !idle) {
- onCameraMoveListener.onCameraMove();
- }
-
- // new API
if (!onCameraMove.isEmpty() && !idle) {
for (OnCameraMoveListener cameraMoveListener : onCameraMove) {
cameraMoveListener.onCameraMove();
@@ -161,12 +123,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
}
private void executeOnCameraMoveCancelled() {
- // deprecated API
- if (onCameraMoveCanceledListener != null && !idle) {
- onCameraMoveCanceledListener.onCameraMoveCanceled();
- }
-
- // new API
if (!onCameraMoveCanceled.isEmpty() && !idle) {
for (OnCameraMoveCanceledListener cameraMoveCanceledListener : onCameraMoveCanceled) {
cameraMoveCanceledListener.onCameraMoveCanceled();
@@ -179,13 +135,6 @@ class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, M
return;
}
idle = true;
-
- // deprecated API
- if (onCameraIdleListener != null) {
- onCameraIdleListener.onCameraIdle();
- }
-
- // new API
if (!onCameraIdle.isEmpty()) {
for (OnCameraIdleListener cameraIdleListener : onCameraIdle) {
cameraIdleListener.onCameraIdle();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
index d589b2e0e3..d82eec45ea 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
@@ -47,12 +47,6 @@ final class MapGestureDetector {
private final AnnotationManager annotationManager;
private final CameraChangeDispatcher cameraChangeDispatcher;
- // deprecated map touch API
- private MapboxMap.OnMapClickListener onMapClickListener;
- private MapboxMap.OnMapLongClickListener onMapLongClickListener;
- private MapboxMap.OnFlingListener onFlingListener;
- private MapboxMap.OnScrollListener onScrollListener;
-
// new map touch API
private final CopyOnWriteArrayList<MapboxMap.OnMapClickListener> onMapClickListenerList
= new CopyOnWriteArrayList<>();
@@ -63,9 +57,6 @@ final class MapGestureDetector {
private final CopyOnWriteArrayList<MapboxMap.OnFlingListener> onFlingListenerList
= new CopyOnWriteArrayList<>();
- private final CopyOnWriteArrayList<MapboxMap.OnScrollListener> onScrollListenerList
- = new CopyOnWriteArrayList<>();
-
private final CopyOnWriteArrayList<MapboxMap.OnMoveListener> onMoveListenerList
= new CopyOnWriteArrayList<>();
@@ -457,7 +448,6 @@ final class MapGestureDetector {
// Scroll the map
transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
- notifyOnScrollListeners();
notifyOnMoveListeners(detector);
}
return true;
@@ -920,12 +910,6 @@ final class MapGestureDetector {
}
void notifyOnMapClickListeners(PointF tapPoint) {
- // deprecated API
- if (onMapClickListener != null) {
- onMapClickListener.onMapClick(projection.fromScreenLocation(tapPoint));
- }
-
- // new API
for (MapboxMap.OnMapClickListener listener : onMapClickListenerList) {
if (listener.onMapClick(projection.fromScreenLocation(tapPoint))) {
return;
@@ -934,12 +918,6 @@ final class MapGestureDetector {
}
void notifyOnMapLongClickListeners(PointF longClickPoint) {
- // deprecated API
- if (onMapLongClickListener != null) {
- onMapLongClickListener.onMapLongClick(projection.fromScreenLocation(longClickPoint));
- }
-
- // new API
for (MapboxMap.OnMapLongClickListener listener : onMapLongClickListenerList) {
if (listener.onMapLongClick(projection.fromScreenLocation(longClickPoint))) {
return;
@@ -948,29 +926,11 @@ final class MapGestureDetector {
}
void notifyOnFlingListeners() {
- // deprecated API
- if (onFlingListener != null) {
- onFlingListener.onFling();
- }
-
- // new API
for (MapboxMap.OnFlingListener listener : onFlingListenerList) {
listener.onFling();
}
}
- void notifyOnScrollListeners() {
- //deprecated API
- if (onScrollListener != null) {
- onScrollListener.onScroll();
- }
-
- // new API
- for (MapboxMap.OnScrollListener listener : onScrollListenerList) {
- listener.onScroll();
- }
- }
-
void notifyOnMoveBeginListeners(MoveGestureDetector detector) {
for (MapboxMap.OnMoveListener listener : onMoveListenerList) {
listener.onMoveBegin(detector);
@@ -1043,22 +1003,6 @@ final class MapGestureDetector {
}
}
- void setOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
- this.onMapClickListener = onMapClickListener;
- }
-
- void setOnMapLongClickListener(MapboxMap.OnMapLongClickListener onMapLongClickListener) {
- this.onMapLongClickListener = onMapLongClickListener;
- }
-
- void setOnFlingListener(MapboxMap.OnFlingListener onFlingListener) {
- this.onFlingListener = onFlingListener;
- }
-
- void setOnScrollListener(MapboxMap.OnScrollListener onScrollListener) {
- this.onScrollListener = onScrollListener;
- }
-
void addOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
onMapClickListenerList.add(onMapClickListener);
}
@@ -1083,14 +1027,6 @@ final class MapGestureDetector {
onFlingListenerList.remove(onFlingListener);
}
- void addOnScrollListener(MapboxMap.OnScrollListener onScrollListener) {
- onScrollListenerList.add(onScrollListener);
- }
-
- void removeOnScrollListener(MapboxMap.OnScrollListener onScrollListener) {
- onScrollListenerList.remove(onScrollListener);
- }
-
void addOnMoveListener(MapboxMap.OnMoveListener listener) {
onMoveListenerList.add(listener);
}
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 90046dc5b8..3b1352e153 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
@@ -1026,11 +1026,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
private class GesturesManagerInteractionListener implements MapboxMap.OnGesturesManagerInteractionListener {
@Override
- public void onSetMapClickListener(MapboxMap.OnMapClickListener listener) {
- mapGestureDetector.setOnMapClickListener(listener);
- }
-
- @Override
public void onAddMapClickListener(MapboxMap.OnMapClickListener listener) {
mapGestureDetector.addOnMapClickListener(listener);
}
@@ -1041,11 +1036,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
@Override
- public void onSetMapLongClickListener(MapboxMap.OnMapLongClickListener listener) {
- mapGestureDetector.setOnMapLongClickListener(listener);
- }
-
- @Override
public void onAddMapLongClickListener(MapboxMap.OnMapLongClickListener listener) {
mapGestureDetector.addOnMapLongClickListener(listener);
}
@@ -1056,26 +1046,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
}
@Override
- public void onSetScrollListener(MapboxMap.OnScrollListener listener) {
- mapGestureDetector.setOnScrollListener(listener);
- }
-
- @Override
- public void onAddScrollListener(MapboxMap.OnScrollListener listener) {
- mapGestureDetector.addOnScrollListener(listener);
- }
-
- @Override
- public void onRemoveScrollListener(MapboxMap.OnScrollListener listener) {
- mapGestureDetector.removeOnScrollListener(listener);
- }
-
- @Override
- public void onSetFlingListener(MapboxMap.OnFlingListener listener) {
- mapGestureDetector.setOnFlingListener(listener);
- }
-
- @Override
public void onAddFlingListener(MapboxMap.OnFlingListener listener) {
mapGestureDetector.addOnFlingListener(listener);
}
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 fd80f899e0..7b9484d309 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
@@ -1792,29 +1792,6 @@ public final class MapboxMap {
//
/**
- * Sets a callback that's invoked on every change in camera position.
- *
- * @param listener The callback that's invoked on every camera change position.
- * To unset the callback, use null.
- */
- @Deprecated
- public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) {
- transform.setOnCameraChangeListener(listener);
- }
-
- /**
- * Sets a callback that is invoked when camera movement has ended.
- *
- * @param listener the listener to notify
- * @deprecated use {@link #addOnCameraIdleListener(OnCameraIdleListener)}
- * and {@link #removeOnCameraIdleListener(OnCameraIdleListener)} instead
- */
- @Deprecated
- public void setOnCameraIdleListener(@Nullable OnCameraIdleListener listener) {
- cameraChangeDispatcher.setOnCameraIdleListener(listener);
- }
-
- /**
* Adds a callback that is invoked when camera movement has ended.
*
* @param listener the listener to notify
@@ -1833,18 +1810,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that is invoked when camera movement was cancelled.
- *
- * @param listener the listener to notify
- * @deprecated use {@link #addOnCameraMoveCancelListener(OnCameraMoveCanceledListener)} and
- * {@link #removeOnCameraMoveCancelListener(OnCameraMoveCanceledListener)} instead
- */
- @Deprecated
- public void setOnCameraMoveCancelListener(@Nullable OnCameraMoveCanceledListener listener) {
- cameraChangeDispatcher.setOnCameraMoveCanceledListener(listener);
- }
-
- /**
* Adds a callback that is invoked when camera movement was cancelled.
*
* @param listener the listener to notify
@@ -1863,18 +1828,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that is invoked when camera movement has started.
- *
- * @param listener the listener to notify
- * @deprecated use {@link #addOnCameraMoveStartedListener(OnCameraMoveStartedListener)} and
- * {@link #removeOnCameraMoveStartedListener(OnCameraMoveStartedListener)} instead
- */
- @Deprecated
- public void setOnCameraMoveStartedListener(@Nullable OnCameraMoveStartedListener listener) {
- cameraChangeDispatcher.setOnCameraMoveStartedListener(listener);
- }
-
- /**
* Adds a callback that is invoked when camera movement has started.
*
* @param listener the listener to notify
@@ -1893,18 +1846,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that is invoked when camera position changes.
- *
- * @param listener the listener to notify
- * @deprecated use {@link #addOnCameraMoveListener(OnCameraMoveListener)} and
- * {@link #removeOnCameraMoveListener(OnCameraMoveListener)}instead
- */
- @Deprecated
- public void setOnCameraMoveListener(@Nullable OnCameraMoveListener listener) {
- cameraChangeDispatcher.setOnCameraMoveListener(listener);
- }
-
- /**
* Adds a callback that is invoked when camera position changes.
*
* @param listener the listener to notify
@@ -1940,48 +1881,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that's invoked when the map is scrolled.
- *
- * @param listener The callback that's invoked when the map is scrolled.
- * To unset the callback, use null.
- * @deprecated Use {@link #addOnScrollListener(OnScrollListener)} instead.
- */
- @Deprecated
- public void setOnScrollListener(@Nullable OnScrollListener listener) {
- onGesturesManagerInteractionListener.onSetScrollListener(listener);
- }
-
- /**
- * Adds a callback that's invoked when the map is scrolled.
- *
- * @param listener The callback that's invoked when the map is scrolled.
- */
- public void addOnScrollListener(@NonNull OnScrollListener listener) {
- onGesturesManagerInteractionListener.onAddScrollListener(listener);
- }
-
- /**
- * Removes a callback that's invoked when the map is scrolled.
- *
- * @param listener The callback that's invoked when the map is scrolled.
- */
- public void removeOnScrollListener(@NonNull OnScrollListener listener) {
- onGesturesManagerInteractionListener.onRemoveScrollListener(listener);
- }
-
- /**
- * Sets a callback that's invoked when the map is flinged.
- *
- * @param listener The callback that's invoked when the map is flinged.
- * To unset the callback, use null.
- * @deprecated Use {@link #addOnFlingListener(OnFlingListener)} instead.
- */
- @Deprecated
- public void setOnFlingListener(@Nullable OnFlingListener listener) {
- onGesturesManagerInteractionListener.onSetFlingListener(listener);
- }
-
- /**
* Adds a callback that's invoked when the map is flinged.
*
* @param listener The callback that's invoked when the map is flinged.
@@ -2107,18 +2006,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that's invoked when the user clicks on the map view.
- *
- * @param listener The callback that's invoked when the user clicks on the map view.
- * To unset the callback, use null.
- * @deprecated Use {@link #addOnMapClickListener(OnMapClickListener)} instead.
- */
- @Deprecated
- public void setOnMapClickListener(@Nullable OnMapClickListener listener) {
- onGesturesManagerInteractionListener.onSetMapClickListener(listener);
- }
-
- /**
* Adds a callback that's invoked when the user clicks on the map view.
*
* @param listener The callback that's invoked when the user clicks on the map view.
@@ -2137,18 +2024,6 @@ public final class MapboxMap {
}
/**
- * Sets a callback that's invoked when the user long clicks on the map view.
- *
- * @param listener The callback that's invoked when the user long clicks on the map view.
- * To unset the callback, use null.
- * @deprecated Use {@link #addOnMapLongClickListener(OnMapLongClickListener)} instead.
- */
- @Deprecated
- public void setOnMapLongClickListener(@Nullable OnMapLongClickListener listener) {
- onGesturesManagerInteractionListener.onSetMapLongClickListener(listener);
- }
-
- /**
* Adds a callback that's invoked when the user long clicks on the map view.
*
* @param listener The callback that's invoked when the user long clicks on the map view.
@@ -2325,7 +2200,7 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the map is flinged.
*
- * @see MapboxMap#setOnFlingListener(OnFlingListener)
+ * @see MapboxMap#addOnFlingListener(OnFlingListener)
*/
public interface OnFlingListener {
/**
@@ -2335,20 +2210,6 @@ public final class MapboxMap {
}
/**
- * Interface definition for a callback to be invoked when the map is scrolled.
- *
- * @see MapboxMap#setOnScrollListener(OnScrollListener)
- * @deprecated Use {@link OnMoveListener} instead.
- */
- @Deprecated
- public interface OnScrollListener {
- /**
- * Called when the map is scrolled.
- */
- void onScroll();
- }
-
- /**
* Interface definition for a callback to be invoked when the map is moved.
*
* @see MapboxMap#addOnMoveListener(OnMoveListener)
@@ -2401,25 +2262,6 @@ public final class MapboxMap {
}
/**
- * Interface definition for a callback to be invoked when the camera changes position.
- *
- * @deprecated Replaced by {@link MapboxMap.OnCameraMoveStartedListener}, {@link MapboxMap.OnCameraMoveListener} and
- * {@link MapboxMap.OnCameraIdleListener}. The order in which the deprecated onCameraChange method will be called in
- * relation to the methods in the new camera change listeners is undefined.
- */
- @Deprecated
- public interface OnCameraChangeListener {
- /**
- * Called after the camera position has changed. During an animation,
- * this listener may not be notified of intermediate camera positions.
- * It is always called for the final position in the animation.
- *
- * @param position The CameraPosition at the end of the last camera change.
- */
- void onCameraChange(CameraPosition position);
- }
-
- /**
* Interface definition for a callback to be invoked for when the camera motion starts.
*/
public interface OnCameraMoveStartedListener {
@@ -2503,26 +2345,15 @@ public final class MapboxMap {
* related to touch and click events.
*/
interface OnGesturesManagerInteractionListener {
- void onSetMapClickListener(OnMapClickListener listener);
void onAddMapClickListener(OnMapClickListener listener);
void onRemoveMapClickListener(OnMapClickListener listener);
- void onSetMapLongClickListener(OnMapLongClickListener listener);
-
void onAddMapLongClickListener(OnMapLongClickListener listener);
void onRemoveMapLongClickListener(OnMapLongClickListener listener);
- void onSetScrollListener(OnScrollListener listener);
-
- void onAddScrollListener(OnScrollListener listener);
-
- void onRemoveScrollListener(OnScrollListener listener);
-
- void onSetFlingListener(OnFlingListener listener);
-
void onAddFlingListener(OnFlingListener listener);
void onRemoveFlingListener(OnFlingListener listener);
@@ -2554,7 +2385,7 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the user clicks on the map view.
*
- * @see MapboxMap#setOnMapClickListener(OnMapClickListener)
+ * @see MapboxMap#addOnMapClickListener(OnMapClickListener)
*/
public interface OnMapClickListener {
/**
@@ -2570,7 +2401,7 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the user long clicks on the map view.
*
- * @see MapboxMap#setOnMapLongClickListener(OnMapLongClickListener)
+ * @see MapboxMap#addOnMapLongClickListener(OnMapLongClickListener)
*/
public interface OnMapLongClickListener {
/**
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Telemetry.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Telemetry.java
deleted file mode 100644
index 833978d8fd..0000000000
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Telemetry.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.mapbox.mapboxsdk.maps;
-
-import com.mapbox.android.telemetry.SessionInterval;
-import com.mapbox.mapboxsdk.module.telemetry.TelemetryImpl;
-
-/**
- * @deprecated use {@link TelemetryImpl} instead.
- */
-@Deprecated
-public class Telemetry {
-
- @Deprecated
- public static void initialize() {
- // no-op
- }
-
- /**
- * Set the debug logging state of telemetry.
- *
- * @param debugLoggingEnabled true to enable logging
- * @deprecated use {@link TelemetryImpl#updateDebugLoggingEnabled(boolean)} instead
- */
- @Deprecated
- public static void updateDebugLoggingEnabled(boolean debugLoggingEnabled) {
- TelemetryImpl.updateDebugLoggingEnabled(debugLoggingEnabled);
- }
-
- /**
- * Update the telemetry rotation session id interval
- *
- * @param interval the selected session interval
- * @return true if rotation session id was updated
- * @deprecated use {@link TelemetryImpl#setSessionIdRotationInterval(int)} instead
- */
- @Deprecated
- public static boolean updateSessionIdRotationInterval(SessionInterval interval) {
- return TelemetryImpl.updateSessionIdRotationInterval(interval);
- }
-
- /**
- * Method to be called when an end-user has selected to participate in telemetry collection.
- *
- * @deprecated use {@link TelemetryImpl#setUserTelemetryRequestState(boolean)}
- * with parameter true instead
- */
- @Deprecated
- public static void enableOnUserRequest() {
- TelemetryImpl.enableOnUserRequest();
- }
-
- /**
- * Method to be called when an end-user has selected to opt-out of telemetry collection.
- *
- * @deprecated use {@link TelemetryImpl#setUserTelemetryRequestState(boolean)}
- * with parameter false instead
- */
- @Deprecated
- public static void disableOnUserRequest() {
- TelemetryImpl.disableOnUserRequest();
- }
-} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
index 41bb70f9dc..6be45e3000 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
@@ -18,8 +18,7 @@ import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
/**
* Resembles the current Map transformation.
* <p>
- * Responsible for synchronising {@link CameraPosition} state and notifying
- * {@link com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraChangeListener}.
+ * Responsible for synchronising {@link CameraPosition} state and notifying camera change listeners.
* </p>
*/
final class Transform implements MapView.OnCameraDidChangeListener {
@@ -34,8 +33,6 @@ final class Transform implements MapView.OnCameraDidChangeListener {
private CameraPosition cameraPosition;
private MapboxMap.CancelableCallback cameraCancelableCallback;
- private MapboxMap.OnCameraChangeListener onCameraChangeListener;
-
private CameraChangeDispatcher cameraChangeDispatcher;
private final MapView.OnCameraDidChangeListener moveByChangeListener = new MapView.OnCameraDidChangeListener() {
@@ -174,9 +171,6 @@ final class Transform implements MapView.OnCameraDidChangeListener {
}
this.cameraPosition = cameraPosition;
- if (onCameraChangeListener != null) {
- onCameraChangeListener.onCameraChange(this.cameraPosition);
- }
}
return cameraPosition;
}
@@ -216,14 +210,6 @@ final class Transform implements MapView.OnCameraDidChangeListener {
}
//
- // Camera change listener API
- //
-
- void setOnCameraChangeListener(@Nullable MapboxMap.OnCameraChangeListener listener) {
- this.onCameraChangeListener = listener;
- }
-
- //
// non Camera API
//
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java
index ad761ac965..4ce020d263 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/TelemetryImpl.java
@@ -2,45 +2,25 @@ package com.mapbox.mapboxsdk.module.telemetry;
import android.content.Context;
import android.support.annotation.NonNull;
-
import com.mapbox.android.telemetry.AppUserTurnstile;
import com.mapbox.android.telemetry.Event;
import com.mapbox.android.telemetry.MapEventFactory;
import com.mapbox.android.telemetry.MapState;
import com.mapbox.android.telemetry.MapboxTelemetry;
-import com.mapbox.android.telemetry.SessionInterval;
import com.mapbox.android.telemetry.TelemetryEnabler;
+import com.mapbox.android.telemetry.SessionInterval;
+
import com.mapbox.mapboxsdk.BuildConfig;
-import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition;
import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition;
-import java.lang.reflect.Field;
-
public class TelemetryImpl implements TelemetryDefinition {
- private static final String TAG = "Mbgl-TelemetryImpl";
- private static TelemetryImpl instance;
private MapboxTelemetry telemetry;
- /**
- * Get a single instance of TelemetryImpl.
- *
- * @return instance of Telemetry
- * @deprecated reference instance from Mapbox.java instead
- */
- @Deprecated
- public static synchronized TelemetryImpl getInstance() {
- if (instance == null) {
- instance = new TelemetryImpl();
- }
- return instance;
- }
-
- private TelemetryImpl() {
+ public TelemetryImpl() {
Context appContext = Mapbox.getApplicationContext();
String accessToken = Mapbox.getAccessToken();
telemetry = new MapboxTelemetry(appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT);
@@ -123,68 +103,4 @@ public class TelemetryImpl implements TelemetryDefinition {
offlineDefinition.getStyleURL())
);
}
-
- /**
- * Set the debug logging state of telemetry.
- *
- * @param debugLoggingEnabled true to enable logging
- * @deprecated use {@link #setDebugLoggingEnabled(boolean)} instead
- */
- @Deprecated
- public static void updateDebugLoggingEnabled(boolean debugLoggingEnabled) {
- TelemetryDefinition definition = Mapbox.getTelemetry();
- if (definition != null) {
- definition.setDebugLoggingEnabled(debugLoggingEnabled);
- }
- }
-
- /**
- * Update the telemetry rotation session id interval
- *
- * @param interval the selected session interval
- * @return true if rotation session id was updated
- * @deprecated use {@link #setSessionIdRotationInterval(int)} instead
- */
- @Deprecated
- public static boolean updateSessionIdRotationInterval(SessionInterval interval) {
- try {
- Field field = interval.getClass().getDeclaredField("interval");
- field.setAccessible(true);
- Integer intervalValue = (Integer) field.get(interval);
- TelemetryDefinition definition = Mapbox.getTelemetry();
- if (definition != null) {
- return definition.setSessionIdRotationInterval(intervalValue);
- }
- } catch (Exception exception) {
- Logger.e(TAG, "Exception occurred when updating session id rotation interval", exception);
- MapStrictMode.strictModeViolation(exception);
- }
- return false;
- }
-
- /**
- * Method to be called when an end-user has selected to participate in telemetry collection.
- *
- * @deprecated use {@link #setUserTelemetryRequestState(boolean)} with parameter true instead
- */
- @Deprecated
- public static void enableOnUserRequest() {
- TelemetryDefinition definition = Mapbox.getTelemetry();
- if (definition != null) {
- definition.setUserTelemetryRequestState(true);
- }
- }
-
- /**
- * Method to be called when an end-user has selected to opt-out of telemetry collection.
- *
- * @deprecated use {@link #setUserTelemetryRequestState(boolean)} with parameter false instead
- */
- @Deprecated
- public static void disableOnUserRequest() {
- TelemetryDefinition definition = Mapbox.getTelemetry();
- if (definition != null) {
- definition.setUserTelemetryRequestState(false);
- }
- }
-}
+} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
index 5de55f47c9..079ae3f70a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapTouchListenersTest.java
@@ -70,18 +70,6 @@ public class MapTouchListenersTest {
}
@Test
- public void onScrollListenerTest() throws Exception {
- MapboxMap.OnScrollListener listener = mock(MapboxMap.OnScrollListener.class);
- mapGestureDetector.addOnScrollListener(listener);
- mapGestureDetector.notifyOnScrollListeners();
- verify(listener, times(1)).onScroll();
-
- mapGestureDetector.removeOnScrollListener(listener);
- mapGestureDetector.notifyOnScrollListeners();
- verify(listener, times(1)).onScroll();
- }
-
- @Test
public void onMoveListenerTest() throws Exception {
MapboxMap.OnMoveListener listener = mock(MapboxMap.OnMoveListener.class);
MoveGestureDetector detector = mock(MoveGestureDetector.class);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
index af19643862..1b2da31758 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java
@@ -50,6 +50,15 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On
private MapView mapView;
private boolean cameraState;
+ private MapboxMap.OnCameraIdleListener cameraIdleListener = new MapboxMap.OnCameraIdleListener() {
+ @Override
+ public void onCameraIdle() {
+ if (mapboxMap != null) {
+ Timber.w(mapboxMap.getCameraPosition().toString());
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -66,7 +75,7 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On
mapboxMap = map;
mapboxMap.getUiSettings().setAttributionEnabled(false);
mapboxMap.getUiSettings().setLogoEnabled(false);
- mapboxMap.setOnCameraChangeListener(position -> Timber.w(position.toString()));
+ mapboxMap.addOnCameraIdleListener(cameraIdleListener);
// handle move button clicks
View moveButton = findViewById(R.id.cameraMoveButton);
@@ -149,6 +158,9 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnCameraIdleListener(cameraIdleListener);
+ }
mapView.onDestroy();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index b89961b003..ebad68963f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -60,7 +60,7 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
fab.setOnClickListener(this);
// listen to long click events to toggle logging camera changes
- mapboxMap.setOnMapLongClickListener(this);
+ mapboxMap.addOnMapLongClickListener(this);
}
@Override
@@ -124,6 +124,9 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapLongClickListener(this);
+ }
mapView.onDestroy();
}
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 1160fafe61..246cd962bc 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
@@ -1,9 +1,11 @@
package com.mapbox.mapboxsdk.testapp.activity.camera;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import com.mapbox.mapboxsdk.constants.Style;
+import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
@@ -19,13 +21,22 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
private MapView mapView;
private MapboxMap mapboxMap;
- @Override
+ private MapboxMap.OnMapClickListener clickListener = new MapboxMap.OnMapClickListener() {
+ @Override
+ public boolean onMapClick(@NonNull LatLng point) {
+ if (mapboxMap != null) {
+ mapboxMap.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style));
+ }
+ return true;
+ }
+ };
+ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maxmin_zoom);
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
@@ -35,10 +46,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
mapboxMap = map;
mapboxMap.setMinZoomPreference(3);
mapboxMap.setMaxZoomPreference(5);
- mapboxMap.setOnMapClickListener(point -> {
- map.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style));
- return false;
- });
+ mapboxMap.addOnMapClickListener(clickListener);
}
@Override
@@ -74,6 +82,9 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapClickListener(clickListener);
+ }
mapView.onDestroy();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
index 1a4f4e2adb..ee9733357e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java
@@ -15,6 +15,7 @@ import com.google.gson.JsonElement;
import com.mapbox.geojson.Feature;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Marker;
+import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
@@ -34,12 +35,37 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
private MapboxMap mapboxMap;
private Marker marker;
+ private MapboxMap.OnMapClickListener mapClickListener = new MapboxMap.OnMapClickListener() {
+ @Override
+ public boolean onMapClick(@NonNull LatLng point) {
+ final float density = getResources().getDisplayMetrics().density;
+ final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
+ Timber.i(
+ "Requesting features for %sx%s (%sx%s adjusted for density)",
+ pixel.x, pixel.y, pixel.x / density, pixel.y / density
+ );
+ List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
+
+ // Debug output
+ debugOutput(features);
+
+ // Remove any previous markers
+ if (marker != null) {
+ mapboxMap.removeMarker(marker);
+ }
+
+ // Add a marker on the clicked point
+ marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
+ mapboxMap.selectMarker(marker);
+ return true;
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_query_features_point);
- final float density = getResources().getDisplayMetrics().density;
// Initialize map as normal
mapView = (MapView) findViewById(R.id.mapView);
@@ -51,31 +77,8 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
addCustomInfoWindowAdapter(mapboxMap);
// Add a click listener
- mapboxMap.setOnMapClickListener(point -> {
- // Query
- final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
- Timber.i(
- "Requesting features for %sx%s (%sx%s adjusted for density)",
- pixel.x, pixel.y, pixel.x / density, pixel.y / density
- );
- List<Feature> features = mapboxMap.queryRenderedFeatures(pixel);
-
- // Debug output
- debugOutput(features);
-
- // Remove any previous markers
- if (marker != null) {
- mapboxMap.removeMarker(marker);
- }
-
- // Add a marker on the clicked point
- marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
- mapboxMap.selectMarker(marker);
-
- return false;
- });
+ mapboxMap.addOnMapClickListener(mapClickListener);
});
-
}
private void debugOutput(List<Feature> features) {
@@ -166,6 +169,9 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapClickListener(mapClickListener);
+ }
mapView.onDestroy();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
index cca87bd0fb..31efe80091 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.infowindow;
import android.graphics.Color;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
@@ -28,13 +29,39 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
private MapboxMap mapboxMap;
private MapView mapView;
+ private MarkerView marker;
+
+ private MapboxMap.OnMapClickListener mapClickListener = new MapboxMap.OnMapClickListener() {
+ @Override
+ public boolean onMapClick(@NonNull LatLng point) {
+ if (marker == null) {
+ return false;
+ }
+
+ // Distance from click to marker
+ double distanceKm = marker.getPosition().distanceTo(point) / 1000;
+
+ // Get the info window
+ final InfoWindow infoWindow = marker.getInfoWindow();
+
+ // Get the view from the info window
+ if (infoWindow != null && infoWindow.getView() != null) {
+ // Set the new text on the text view in the info window
+ TextView textView = (TextView) infoWindow.getView();
+ textView.setText(String.format(Locale.getDefault(), "%.2fkm", distanceKm));
+ // Update the info window position (as the text length changes)
+ textView.post(infoWindow::update);
+ }
+ return true;
+ }
+ };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_infowindow_adapter);
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
@@ -50,30 +77,11 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
mapboxMap.getUiSettings().setDeselectMarkersOnTap(false);
// Add a marker
- final MarkerView marker = addMarker(mapboxMap);
+ marker = addMarker(mapboxMap);
mapboxMap.selectMarker(marker);
// On map click, change the info window contents
- mapboxMap.setOnMapClickListener(point -> {
- // Distance from click to marker
- double distanceKm = marker.getPosition().distanceTo(point) / 1000;
-
- // Get the info window
- final InfoWindow infoWindow = marker.getInfoWindow();
-
- // Get the view from the info window
- if (infoWindow != null && infoWindow.getView() != null) {
- // Set the new text on the text view in the info window
- TextView textView = (TextView) infoWindow.getView();
- textView.setText(String.format(Locale.getDefault(), "%.2fkm", distanceKm));
- textView.post(() -> {
- // Update the info window position (as the text length changes)
- infoWindow.update();
- });
- }
-
- return false;
- });
+ mapboxMap.addOnMapClickListener(mapClickListener);
// Focus on Paris
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(PARIS));
@@ -133,6 +141,9 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapClickListener(mapClickListener);
+ }
mapView.onDestroy();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
index 57a1412b55..95bb0d2324 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java
@@ -24,13 +24,32 @@ import java.text.DecimalFormat;
* </p>
*/
public class InfoWindowActivity extends AppCompatActivity
- implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener,
- MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener {
+ implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnInfoWindowClickListener,
+ MapboxMap.OnInfoWindowLongClickListener {
private MapboxMap mapboxMap;
private MapView mapView;
private Marker customMarker;
+ private MapboxMap.OnMapLongClickListener mapLongClickListener = new MapboxMap.OnMapLongClickListener() {
+ @Override
+ public boolean onMapLongClick(@NonNull LatLng point) {
+ if (customMarker != null) {
+ // Remove previous added marker
+ mapboxMap.removeAnnotation(customMarker);
+ customMarker = null;
+ }
+
+ // Add marker on long click location with default marker image
+ customMarker = mapboxMap.addMarker(new MarkerOptions()
+ .title("Custom Marker")
+ .snippet(new DecimalFormat("#.#####").format(point.getLatitude()) + ", "
+ + new DecimalFormat("#.#####").format(point.getLongitude()))
+ .position(point));
+ return true;
+ }
+ };
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -77,7 +96,7 @@ public class InfoWindowActivity extends AppCompatActivity
private void addInfoWindowListeners() {
mapboxMap.setOnInfoWindowCloseListener(this);
- mapboxMap.setOnMapLongClickListener(this);
+ mapboxMap.addOnMapLongClickListener(mapLongClickListener);
mapboxMap.setOnInfoWindowClickListener(this);
mapboxMap.setOnInfoWindowLongClickListener(this);
}
@@ -109,24 +128,6 @@ public class InfoWindowActivity extends AppCompatActivity
}
@Override
- public boolean onMapLongClick(@NonNull LatLng point) {
- if (customMarker != null) {
- // Remove previous added marker
- mapboxMap.removeAnnotation(customMarker);
- customMarker = null;
- }
-
- // Add marker on long click location with default marker image
- customMarker = mapboxMap.addMarker(new MarkerOptions()
- .title("Custom Marker")
- .snippet(new DecimalFormat("#.#####").format(point.getLatitude()) + ", "
- + new DecimalFormat("#.#####").format(point.getLongitude()))
- .position(point));
-
- return false;
- }
-
- @Override
protected void onStart() {
super.onStart();
mapView.onStart();
@@ -159,6 +160,9 @@ public class InfoWindowActivity extends AppCompatActivity
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null) {
+ mapboxMap.removeOnMapLongClickListener(mapLongClickListener);
+ }
mapView.onDestroy();
}
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 c195372d90..7221b71da3 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
@@ -26,6 +26,7 @@ import com.mapbox.mapboxsdk.testapp.R;
import java.util.List;
import java.util.Locale;
+import com.mapbox.mapboxsdk.testapp.utils.IdleZoomListener;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
@@ -38,7 +39,8 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
private MapView mapView;
private MapboxMap mapboxMap;
private ActionBarDrawerToggle actionBarDrawerToggle;
- private int currentStyleIndex = 0;
+ private int currentStyleIndex;
+ private IdleZoomListener idleZoomListener;
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
@@ -66,8 +68,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
-
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(this,
drawerLayout,
R.string.navigation_drawer_open,
@@ -79,7 +80,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setupMapView(Bundle savedInstanceState) {
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
mapView.addOnDidFinishLoadingStyleListener(() -> {
if (mapboxMap != null) {
@@ -105,7 +106,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setFpsView() {
- final TextView fpsView = (TextView) findViewById(R.id.fpsView);
+ final TextView fpsView = findViewById(R.id.fpsView);
mapboxMap.setOnFpsChangedListener(fps ->
fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps))
);
@@ -114,7 +115,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
private void setupNavigationView(List<Layer> layerList) {
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
final LayerListAdapter adapter = new LayerListAdapter(this, layerList);
- ListView listView = (ListView) findViewById(R.id.listView);
+ ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Layer clickedLayer = adapter.getItem(position);
@@ -133,19 +134,17 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void closeNavigationView() {
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.closeDrawers();
}
private void setupZoomView() {
- final TextView textView = (TextView) findViewById(R.id.textZoom);
- mapboxMap.setOnCameraChangeListener(position ->
- textView.setText(String.format(getString(R.string.debug_zoom), position.zoom))
- );
+ final TextView textView = findViewById(R.id.textZoom);
+ mapboxMap.addOnCameraIdleListener(idleZoomListener = new IdleZoomListener(mapboxMap, textView));
}
private void setupDebugChangeView() {
- FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
+ FloatingActionButton fabDebug = findViewById(R.id.fabDebug);
fabDebug.setOnClickListener(view -> {
if (mapboxMap != null) {
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
@@ -155,7 +154,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
}
private void setupStyleChangeView() {
- FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
+ FloatingActionButton fabStyles = findViewById(R.id.fabStyles);
fabStyles.setOnClickListener(view -> {
if (mapboxMap != null) {
currentStyleIndex++;
@@ -205,6 +204,9 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null && idleZoomListener != null) {
+ mapboxMap.removeOnCameraIdleListener(idleZoomListener);
+ }
mapView.onDestroy();
}
@@ -246,8 +248,8 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
if (view == null) {
view = layoutInflater.inflate(android.R.layout.simple_list_item_2, parent, false);
ViewHolder holder = new ViewHolder(
- (TextView) view.findViewById(android.R.id.text1),
- (TextView) view.findViewById(android.R.id.text2)
+ view.findViewById(android.R.id.text1),
+ view.findViewById(android.R.id.text2)
);
view.setTag(holder);
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
index dae0714d42..ef8ec3af78 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
@@ -8,7 +8,6 @@ import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
-import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
@@ -17,6 +16,7 @@ import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.testapp.R;
+import com.mapbox.mapboxsdk.testapp.utils.IdleZoomListener;
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
import java.io.IOException;
@@ -48,6 +48,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
public static final String AMSTERDAM_PARKS_LAYER = "amsterdam-parks-layer";
private MapView mapView;
private MapboxMap mapboxMap;
+ private IdleZoomListener idleListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -55,7 +56,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
setContentView(R.layout.activity_data_driven_style);
// Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
@@ -75,15 +76,9 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void setupDebugZoomView() {
final TextView textView = (TextView) findViewById(R.id.textZoom);
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
- @Override
- public void onCameraChange(CameraPosition position) {
- textView.setText(String.format(getString(R.string.debug_zoom), position.zoom));
- }
- });
+ mapboxMap.addOnCameraIdleListener(idleListener = new IdleZoomListener(mapboxMap, textView));
}
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_data_driven_style, menu);
@@ -123,6 +118,9 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null && idleListener != null) {
+ mapboxMap.removeOnCameraIdleListener(idleListener);
+ }
mapView.onDestroy();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
index 6ca2122672..32535a27d1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.style;
import android.graphics.PointF;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
@@ -9,6 +10,7 @@ import com.google.gson.JsonObject;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Point;
+import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.Property;
@@ -51,6 +53,23 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
private boolean isSelected = false;
private boolean isShowingSymbolLayer = true;
+ private MapboxMap.OnMapClickListener mapClickListener = new MapboxMap.OnMapClickListener() {
+ @Override
+ public boolean onMapClick(@NonNull LatLng point) {
+ PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
+ List<Feature> featureList = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
+ if (!featureList.isEmpty()) {
+ Feature feature = featureList.get(0);
+ boolean selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED);
+ isSelected = !selectedNow;
+ updateSource();
+ } else {
+ Timber.e("No features found");
+ }
+ return true;
+ }
+ };
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -62,7 +81,7 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
mapboxMap = map;
updateSource();
addLayer();
- addMapClickListener();
+ map.addOnMapClickListener(mapClickListener);
});
}
@@ -113,23 +132,6 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
mapboxMap.addLayer(layer);
}
- private void addMapClickListener() {
- mapboxMap.setOnMapClickListener(point -> {
- PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
- List<Feature> featureList = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID);
- if (!featureList.isEmpty()) {
- Feature feature = featureList.get(0);
- boolean selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED);
- isSelected = !selectedNow;
- updateSource();
- } else {
- Timber.e("No features found");
- }
-
- return false;
- });
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_symbols, menu);
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 7b01f971bf..60849ab6d0 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
@@ -15,6 +15,7 @@ import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
+import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.Style;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
@@ -39,6 +40,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
private MapboxMap mapboxMap;
private ActionBarDrawerToggle actionBarDrawerToggle;
private int currentStyleIndex = 0;
+ private IdleListener idleListener;
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
@@ -67,7 +69,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(this,
drawerLayout,
R.string.navigation_drawer_open,
@@ -103,14 +105,14 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
}
private void setFpsView() {
- final TextView fpsView = (TextView) findViewById(R.id.fpsView);
+ final TextView fpsView = findViewById(R.id.fpsView);
mapboxMap.setOnFpsChangedListener(fps -> fpsView.setText(String.format(Locale.US, "FPS: %4.2f", fps)));
}
private void setupNavigationView(List<Layer> layerList) {
Timber.v("New style loaded with JSON: %s", mapboxMap.getStyleJson());
final LayerListAdapter adapter = new LayerListAdapter(this, layerList);
- ListView listView = (ListView) findViewById(R.id.listView);
+ ListView listView = findViewById(R.id.listView);
listView.setAdapter(adapter);
listView.setOnItemClickListener((parent, view, position, id) -> {
Layer clickedLayer = adapter.getItem(position);
@@ -129,18 +131,17 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
}
private void closeNavigationView() {
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
drawerLayout.closeDrawers();
}
private void setupZoomView() {
- final TextView textView = (TextView) findViewById(R.id.textZoom);
- mapboxMap.setOnCameraChangeListener(position ->
- textView.setText(String.format(getString(R.string.debug_zoom), position.zoom)));
+ final TextView textView = findViewById(R.id.textZoom);
+ mapboxMap.addOnCameraIdleListener(idleListener = new IdleListener(mapboxMap, textView));
}
private void setupDebugChangeView() {
- FloatingActionButton fabDebug = (FloatingActionButton) findViewById(R.id.fabDebug);
+ FloatingActionButton fabDebug = findViewById(R.id.fabDebug);
fabDebug.setOnClickListener(view -> {
if (mapboxMap != null) {
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive());
@@ -150,7 +151,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
}
private void setupStyleChangeView() {
- FloatingActionButton fabStyles = (FloatingActionButton) findViewById(R.id.fabStyles);
+ FloatingActionButton fabStyles = findViewById(R.id.fabStyles);
fabStyles.setOnClickListener(view -> {
if (mapboxMap != null) {
currentStyleIndex++;
@@ -200,6 +201,9 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mapboxMap != null && idleListener != null) {
+ mapboxMap.removeOnCameraIdleListener(idleListener);
+ }
mapView.onDestroy();
}
@@ -241,8 +245,8 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
if (view == null) {
view = layoutInflater.inflate(android.R.layout.simple_list_item_2, parent, false);
ViewHolder holder = new ViewHolder(
- (TextView) view.findViewById(android.R.id.text1),
- (TextView) view.findViewById(android.R.id.text2)
+ view.findViewById(android.R.id.text1),
+ view.findViewById(android.R.id.text2)
);
view.setTag(holder);
}
@@ -262,4 +266,22 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
}
}
}
+
+ private static class IdleListener implements MapboxMap.OnCameraIdleListener {
+
+ private MapboxMap mapboxMap;
+ private TextView textView;
+
+ IdleListener(MapboxMap mapboxMap, TextView textView) {
+ this.mapboxMap = mapboxMap;
+ this.textView = textView;
+ }
+
+ @Override
+ public void onCameraIdle() {
+ Context context = textView.getContext();
+ CameraPosition position = mapboxMap.getCameraPosition();
+ textView.setText(String.format(context.getString(R.string.debug_zoom), position.zoom));
+ }
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IdleZoomListener.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IdleZoomListener.java
new file mode 100644
index 0000000000..80f17ab58e
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IdleZoomListener.java
@@ -0,0 +1,25 @@
+package com.mapbox.mapboxsdk.testapp.utils;
+
+import android.content.Context;
+import android.widget.TextView;
+import com.mapbox.mapboxsdk.camera.CameraPosition;
+import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.testapp.R;
+
+public class IdleZoomListener implements MapboxMap.OnCameraIdleListener {
+
+ private MapboxMap mapboxMap;
+ private TextView textView;
+
+ public IdleZoomListener(MapboxMap mapboxMap, TextView textView) {
+ this.mapboxMap = mapboxMap;
+ this.textView = textView;
+ }
+
+ @Override
+ public void onCameraIdle() {
+ Context context = textView.getContext();
+ CameraPosition position = mapboxMap.getCameraPosition();
+ textView.setText(String.format(context.getString(R.string.debug_zoom), position.zoom));
+ }
+} \ No newline at end of file