From d8bd59468711c07cef98702dcb9dcf7c91c15de7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 29 Jan 2019 14:30:25 +0100 Subject: [android] LocationComponent max fps javadoc --- .../mapboxsdk/location/LocationComponent.java | 41 ++++++++++++++++++++++ .../location/LocationLayerController.java | 3 +- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java') 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 5dc9172672..f27af0a517 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 @@ -25,6 +25,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.location.modes.CameraMode; import com.mapbox.mapboxsdk.location.modes.RenderMode; import com.mapbox.mapboxsdk.log.Logger; +import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener; import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener; @@ -702,6 +703,46 @@ public final class LocationComponent { updateLocation(location, false); } + /** + * Set max FPS at which location animators can output updates. The throttling will only impact the location puck + * and camera tracking smooth animations. + *

+ * Setting this will not impact any other animations schedule with {@link MapboxMap}, gesture animations or + * {@link #zoomWhileTracking(double)}/{@link #tiltWhileTracking(double)}. + *

+ * Use this setting to limit animation rate of the location puck on higher zoom levels to decrease the stress on + * the device's CPU which can directly improve battery life, without sacrificing UX. + *

+ * Example usage: + *

+   * {@code
+   * mapboxMap.addOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
+   *   @Override
+   *   public void onCameraIdle() {
+   *     double zoom = mapboxMap.getCameraPosition().zoom;
+   *     int maxAnimationFps;
+   *     if (zoom < 5) {
+   *       maxAnimationFps = 3;
+   *     } else if (zoom < 10) {
+   *       maxAnimationFps = 5;
+   *     } else if (zoom < 15) {
+   *       maxAnimationFps = 7;
+   *     } else if (zoom < 18) {
+   *       maxAnimationFps = 15;
+   *     } else {
+   *       maxAnimationFps = Integer.MAX_VALUE;
+   *     }
+   *     locationComponent.setMaxAnimationFps(maxAnimationFps);
+   *   }
+   * });
+   * }
+   * 
+ *

+ * If you're looking for a way to throttle the FPS of the whole map, including other animations and gestures, see + * {@link MapView#setMaximumFps(int)}. + * + * @param maxAnimationFps max location animation FPS + */ public void setMaxAnimationFps(int maxAnimationFps) { locationAnimatorCoordinator.setMaxAnimationFps(maxAnimationFps); } 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 c726caacfb..1fa36515a7 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 @@ -447,7 +447,8 @@ final class LocationLayerController { if (renderMode == RenderMode.GPS) { holders.add(new AnimatorListenerHolder(MapboxAnimator.ANIMATOR_LAYER_GPS_BEARING, gpsBearingValueListener)); } else if (renderMode == RenderMode.COMPASS) { - holders.add(new AnimatorListenerHolder(MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING, compassBearingValueListener)); + holders.add( + new AnimatorListenerHolder(MapboxAnimator.ANIMATOR_LAYER_COMPASS_BEARING, compassBearingValueListener)); } if (renderMode == RenderMode.COMPASS || renderMode == RenderMode.NORMAL) { -- cgit v1.2.1