invoke cancelable callback when zoom/tilt while tracking is ignored

This commit is contained in:
Łukasz Paczos
2019-12-03 12:24:05 +01:00
parent 4bde987fb9
commit 9a40605133
2 changed files with 137 additions and 4 deletions

View File

@@ -739,14 +739,15 @@ public final class LocationComponent {
@Nullable MapboxMap.CancelableCallback callback) {
checkActivationState();
if (!isLayerReady) {
notifyUnsuccessfulCameraOperation(callback, null);
return;
} else if (getCameraMode() == CameraMode.NONE) {
Logger.e(TAG, String.format("%s%s",
notifyUnsuccessfulCameraOperation(callback, String.format("%s%s",
"LocationComponent#zoomWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
} else if (locationCameraController.isTransitioning()) {
Logger.e(TAG,
notifyUnsuccessfulCameraOperation(callback,
"LocationComponent#zoomWhileTracking method call is ignored because the camera mode is transitioning");
return;
}
@@ -817,14 +818,15 @@ public final class LocationComponent {
@Nullable MapboxMap.CancelableCallback callback) {
checkActivationState();
if (!isLayerReady) {
notifyUnsuccessfulCameraOperation(callback, null);
return;
} else if (getCameraMode() == CameraMode.NONE) {
Logger.e(TAG, String.format("%s%s",
notifyUnsuccessfulCameraOperation(callback, String.format("%s%s",
"LocationComponent#tiltWhileTracking method can only be used",
" when a camera mode other than CameraMode#NONE is engaged."));
return;
} else if (locationCameraController.isTransitioning()) {
Logger.e(TAG,
notifyUnsuccessfulCameraOperation(callback,
"LocationComponent#tiltWhileTracking method call is ignored because the camera mode is transitioning");
return;
}
@@ -1607,6 +1609,17 @@ public final class LocationComponent {
}
}
private void notifyUnsuccessfulCameraOperation(@Nullable MapboxMap.CancelableCallback callback,
@Nullable String msg) {
if (msg != null) {
Logger.e(TAG, msg);
}
if (callback != null) {
callback.onCancel();
}
}
/**
* Returns whether the location component is activated.
*