summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-12-08 17:32:27 +0100
committerTobrun <tobrun@mapbox.com>2017-12-12 09:18:49 +0100
commitcf026d1932ca380a799dd4263e02dce67d22806b (patch)
tree6ec0ac0e827f0caa9b339a3d027ba9a83de7018e /platform
parent05d2a539fdc2801c67b98c2e09f65989c32331d6 (diff)
downloadqtlocation-mapboxgl-cf026d1932ca380a799dd4263e02dce67d22806b.tar.gz
[android] - post animation callback invocation
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java41
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java23
2 files changed, 36 insertions, 28 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 6bf8342efb..c9bccab07d 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
@@ -710,19 +710,21 @@ public final class MapboxMap {
* @param callback the callback to be invoked when an animation finishes or is canceled
*/
public final void moveCamera(final CameraUpdate update, final MapboxMap.CancelableCallback callback) {
- new Handler().post(new Runnable() {
- @Override
- public void run() {
- transform.moveCamera(MapboxMap.this, update, callback);
- // MapChange.REGION_DID_CHANGE_ANIMATED is not called for `jumpTo`
- // invalidate camera position to provide OnCameraChange event.
- invalidateCameraPosition();
-
- if (callback != null) {
- callback.onFinish();
+ transform.moveCamera(MapboxMap.this, update, callback);
+ // MapChange.REGION_DID_CHANGE_ANIMATED is not called for `jumpTo`
+ // invalidate camera position to provide OnCameraChange event.
+ invalidateCameraPosition();
+
+ if (callback != null) {
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ if (callback != null) {
+ callback.onFinish();
+ }
}
- }
- });
+ });
+ }
}
/**
@@ -846,12 +848,7 @@ public final class MapboxMap {
if (durationMs <= 0) {
throw new IllegalArgumentException("Null duration passed into easeCamera");
}
- new Handler().post(new Runnable() {
- @Override
- public void run() {
- transform.easeCamera(MapboxMap.this, update, durationMs, easingInterpolator, callback, isDismissable);
- }
- });
+ transform.easeCamera(MapboxMap.this, update, durationMs, easingInterpolator, callback, isDismissable);
}
/**
@@ -921,12 +918,8 @@ public final class MapboxMap {
if (durationMs <= 0) {
throw new IllegalArgumentException("Null duration passed into animageCamera");
}
- new Handler().post(new Runnable() {
- @Override
- public void run() {
- transform.animateCamera(MapboxMap.this, update, durationMs, callback);
- }
- });
+
+ transform.animateCamera(MapboxMap.this, update, durationMs, callback);
}
/**
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 16c45ebea2..0d3f0d5e5b 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
@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.maps;
import android.graphics.PointF;
+import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.UiThread;
@@ -82,8 +83,15 @@ final class Transform implements MapView.OnMapChangedListener {
if (change == REGION_DID_CHANGE_ANIMATED) {
updateCameraPosition(invalidateCameraPosition());
if (cameraCancelableCallback != null) {
- cameraCancelableCallback.onFinish();
- cameraCancelableCallback = null;
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ if (cameraCancelableCallback != null) {
+ cameraCancelableCallback.onFinish();
+ cameraCancelableCallback = null;
+ }
+ }
+ });
}
cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
@@ -175,8 +183,15 @@ final class Transform implements MapView.OnMapChangedListener {
// notify animateCamera and easeCamera about cancelling
if (cameraCancelableCallback != null) {
cameraChangeDispatcher.onCameraIdle();
- cameraCancelableCallback.onCancel();
- cameraCancelableCallback = null;
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ if (cameraCancelableCallback != null) {
+ cameraCancelableCallback.onCancel();
+ cameraCancelableCallback = null;
+ }
+ }
+ });
}
// cancel ongoing transitions