[Android] Catch exception onMove (#621)

This commit is contained in:
Robin
2022-12-21 19:35:21 +01:00
committed by GitHub
parent b038aeddb0
commit 1439e05413
2 changed files with 6 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ MapLibre welcomes participation and contributions from everyone. Please read [`C
### 🐞 Bug fixes
* Add your pull request...
* Catches NaN for onMove event ([621](https://github.com/maplibre/maplibre-gl-native/pull/621))
### ⛵ Dependencies

View File

@@ -41,6 +41,8 @@ import static com.mapbox.mapboxsdk.constants.MapboxConstants.ZOOM_RATE;
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE;
import static com.mapbox.mapboxsdk.utils.MathUtils.normalize;
import timber.log.Timber;
/**
* Manages gestures events on a MapView.
*/
@@ -480,7 +482,7 @@ final class MapGestureDetector {
@Override
public boolean onMove(@NonNull MoveGestureDetector detector, float distanceX, float distanceY) {
// first move event is often delivered with no displacement
if (distanceX != 0 || distanceY != 0) {
if (!Float.isNaN(distanceX) && !Float.isNaN(distanceY) && (distanceX != 0 || distanceY != 0)) {
// dispatching camera start event only when the movement actually occurred
cameraChangeDispatcher.onCameraMoveStarted(CameraChangeDispatcher.REASON_API_GESTURE);
@@ -493,6 +495,8 @@ final class MapGestureDetector {
transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
notifyOnMoveListeners(detector);
} else {
Timber.e("Could not call onMove with parameters %s,%s", distanceX, distanceY);
}
return true;
}