diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 50 |
1 files changed, 45 insertions, 5 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 1997375f9e..0fe1e27662 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 @@ -96,6 +96,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { private MapKeyListener mapKeyListener; private MapZoomButtonController mapZoomButtonController; private Bundle savedInstanceState; + private boolean isActivated; @UiThread public MapView(@NonNull Context context) { @@ -371,8 +372,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { */ @UiThread public void onStart() { - ConnectivityReceiver.instance(getContext()).activate(); - FileSource.getInstance(getContext()).activate(); + if (!isActivated) { + ConnectivityReceiver.instance(getContext()).activate(); + FileSource.getInstance(getContext()).activate(); + isActivated = true; + } if (mapboxMap != null) { mapboxMap.onStart(); } @@ -417,8 +421,11 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { mapRenderer.onStop(); } - ConnectivityReceiver.instance(getContext()).deactivate(); - FileSource.getInstance(getContext()).deactivate(); + if (isActivated) { + ConnectivityReceiver.instance(getContext()).deactivate(); + FileSource.getInstance(getContext()).deactivate(); + isActivated = false; + } } /** @@ -851,13 +858,33 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { /** * Remove a callback that's invoked when the map has finished rendering. * - * @param listener The callback that's invoked when the map has finished rendering + * @param listener The callback that's invoked when the map has has finished rendering. */ public void removeOnDidFinishRenderingMapListener(OnDidFinishRenderingMapListener listener) { mapChangeReceiver.removeOnDidFinishRenderingMapListener(listener); } /** + * Set a callback that's invoked when the map has entered the idle state. + * + * @param listener The callback that's invoked when the map has entered the idle state. + */ + public void addOnDidBecomeIdleListener(OnDidBecomeIdleListener listener) { + mapChangeReceiver.addOnDidBecomeIdleListener(listener); + } + + /** + * Remove a callback that's invoked when the map has entered the idle state. + * + * @param listener The callback that's invoked when the map has entered the idle state. + */ + public void removeOnDidBecomeIdleListener(OnDidBecomeIdleListener listener) { + mapChangeReceiver.removeOnDidBecomeIdleListener(listener); + } + + /** + + /** * Set a callback that's invoked when the style has finished loading. * * @param listener The callback that's invoked when the style has finished loading @@ -1031,6 +1058,19 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } /** + * Interface definition for a callback to be invoked when the map has entered the idle state. + * <p> + * {@link MapView#addOnDidBecomeIdleListener(OnDidBecomeIdleListener)} + * </p> + */ + public interface OnDidBecomeIdleListener { + /** + * Called when the map has entered the idle state. + */ + void onDidBecomeIdle(); + } + + /** * Interface definition for a callback to be invoked when the map has loaded the style. * <p> * {@link MapView#addOnDidFailLoadingMapListener(OnDidFailLoadingMapListener)} |