From a0225d6ef70b4ac1854701a2e5d09cf176cc592b Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 21 Mar 2016 20:19:17 +0100 Subject: [PATCH] [android] #4326 - making the code compatible with unit tests again --- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 280f5c77bf9..9ab883c133f 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 @@ -245,11 +245,8 @@ public final void moveCamera(CameraUpdate update) { */ @UiThread public final void moveCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) { - CameraPosition position = update.getCameraPosition(this); - mMapView.jumpTo(position.bearing, position.target, position.tilt, position.zoom); - if (mOnCameraChangeListener != null) { - mOnCameraChangeListener.onCameraChange(mCameraPosition); - } + mCameraPosition = update.getCameraPosition(this); + mMapView.jumpTo(mCameraPosition.bearing, mCameraPosition.target, mCameraPosition.tilt, mCameraPosition.zoom); if (callback != null) { callback.onFinish(); } @@ -289,8 +286,8 @@ public final void easeCamera(CameraUpdate update, int durationMs) { */ @UiThread public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { - CameraPosition position = update.getCameraPosition(this); - mMapView.easeTo(position.bearing, position.target, getDurationNano(durationMs), position.tilt, position.zoom, new CancelableCallback() { + mCameraPosition = update.getCameraPosition(this); + mMapView.easeTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() { @Override public void onCancel() { if (callback != null) { @@ -357,8 +354,8 @@ public final void animateCamera(CameraUpdate update, int durationMs) { */ @UiThread public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { - CameraPosition cameraPosition = update.getCameraPosition(this); - mMapView.flyTo(cameraPosition.bearing, cameraPosition.target, getDurationNano(durationMs), cameraPosition.tilt, cameraPosition.zoom, new CancelableCallback() { + mCameraPosition = update.getCameraPosition(this); + mMapView.flyTo(mCameraPosition.bearing, mCameraPosition.target, getDurationNano(durationMs), mCameraPosition.tilt, mCameraPosition.zoom, new CancelableCallback() { @Override public void onCancel() { if (callback != null) { @@ -396,7 +393,12 @@ private long getDurationNano(long durationMs) { */ private void invalidateCameraPosition() { mInvalidCameraPosition = false; - mCameraPosition = mMapView.invalidateCameraPosition(); + + CameraPosition cameraPosition = mMapView.invalidateCameraPosition(); + if (cameraPosition != null) { + mCameraPosition = cameraPosition; + } + if (mOnCameraChangeListener != null) { mOnCameraChangeListener.onCameraChange(mCameraPosition); }