[android] harden map events creation

This commit is contained in:
Łukasz Paczos
2018-07-17 10:36:47 +02:00
parent aeb85dbd8c
commit a45dd30e44

View File

@@ -22,6 +22,7 @@ import com.mapbox.android.gestures.StandardScaleGestureDetector;
import com.mapbox.android.telemetry.Event;
import com.mapbox.android.telemetry.MapEventFactory;
import com.mapbox.android.telemetry.MapState;
import com.mapbox.android.telemetry.MapboxTelemetry;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -886,11 +887,12 @@ final class MapGestureDetector {
if (cameraPosition != null) {
double zoom = cameraPosition.zoom;
if (isZoomValid(zoom)) {
MapboxTelemetry telemetry = Telemetry.obtainTelemetry();
MapEventFactory mapEventFactory = new MapEventFactory();
LatLng latLng = projection.fromScreenLocation(focalPoint);
MapState state = new MapState(latLng.getLatitude(), latLng.getLongitude(), zoom);
state.setGesture(eventType);
Telemetry.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, state));
telemetry.push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, state));
}
}
}