summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2017-04-18 16:13:15 +0200
committerGitHub <noreply@github.com>2017-04-18 16:13:15 +0200
commit589d71d7adbe4e4dac3e9a7ec97378b2b9a69d93 (patch)
tree8053830c135ab38478e8d5250b53504b0ec0b630 /platform
parent8e9eaaabfc2d1947e63d502116f9d27d2cc645f7 (diff)
downloadqtlocation-mapboxgl-589d71d7adbe4e4dac3e9a7ec97378b2b9a69d93.tar.gz
[android] - post resetting invalidation flag to avoid race condition (#8738)
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java42
1 files changed, 24 insertions, 18 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
index 663202eacc..d7f31b3faf 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
@@ -321,7 +321,7 @@ public class MyLocationView extends View {
setCompass(location.getBearing() - bearing);
}
} else if (myBearingTrackingMode == MyBearingTracking.COMPASS
- && compassListener.isSensorAvailable()) {
+ && compassListener.isSensorAvailable()) {
setCompass(magneticHeading - bearing);
}
}
@@ -336,7 +336,7 @@ public class MyLocationView extends View {
public void onStart() {
if (myBearingTrackingMode == MyBearingTracking.COMPASS
- && compassListener.isSensorAvailable()) {
+ && compassListener.isSensorAvailable()) {
compassListener.onResume();
}
if (isEnabled()) {
@@ -461,7 +461,7 @@ public class MyLocationView extends View {
public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) {
this.myBearingTrackingMode = myBearingTrackingMode;
if (myBearingTrackingMode == MyBearingTracking.COMPASS
- && compassListener.isSensorAvailable()) {
+ && compassListener.isSensorAvailable()) {
compassListener.onResume();
} else {
compassListener.onPause();
@@ -741,7 +741,7 @@ public class MyLocationView extends View {
abstract void invalidate();
}
- private class MyLocationTrackingBehavior extends MyLocationBehavior {
+ private class MyLocationTrackingBehavior extends MyLocationBehavior implements MapboxMap.CancelableCallback {
@Override
void updateLatLng(@NonNull Location location) {
@@ -757,11 +757,11 @@ public class MyLocationView extends View {
locationUpdateTimestamp = SystemClock.elapsedRealtime();
// calculate animation duration
- float animationDuration;
+ int animationDuration;
if (previousUpdateTimeStamp == 0) {
animationDuration = 0;
} else {
- animationDuration = (locationUpdateTimestamp - previousUpdateTimeStamp) * 1.1f
+ animationDuration = (int) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.1f)
/*make animation slightly longer*/;
}
@@ -780,20 +780,10 @@ public class MyLocationView extends View {
// accuracy
updateAccuracy(location);
+ // disable dismiss of tracking settings, enabled in #onFinish
mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(false);
// ease to new camera position with a linear interpolator
- mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), (int) animationDuration,
- false /*linear interpolator*/, new MapboxMap.CancelableCallback() {
- @Override
- public void onCancel() {
-
- }
-
- @Override
- public void onFinish() {
- mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(true);
- }
- });
+ mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, this);
}
@Override
@@ -804,6 +794,22 @@ public class MyLocationView extends View {
screenLocation = new PointF(x, y);
MyLocationView.this.invalidate();
}
+
+ @Override
+ public void onCancel() {
+ //no op
+ }
+
+ @Override
+ public void onFinish() {
+ // Posting to end message queue to avoid race condition #8560
+ post(new Runnable() {
+ @Override
+ public void run() {
+ mapboxMap.getTrackingSettings().setDismissTrackingModeForCameraPositionChange(true);
+ }
+ });
+ }
}
private class MyLocationShowBehavior extends MyLocationBehavior {