[android] - ensure that camera is invalidated before generating telemetry event

This commit is contained in:
Łukasz Paczos
2018-05-31 18:07:15 +02:00
parent a5a86615b5
commit 37b27d2eb5
2 changed files with 12 additions and 15 deletions

View File

@@ -23,6 +23,7 @@ import com.mapbox.android.telemetry.Event;
import com.mapbox.android.telemetry.MapEventFactory;
import com.mapbox.android.telemetry.MapState;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.MathUtils;
@@ -885,20 +886,20 @@ final class MapGestureDetector {
}
private void sendTelemetryEvent(String eventType, PointF focalPoint) {
if (isZoomValid(transform)) {
MapEventFactory mapEventFactory = new MapEventFactory();
LatLng latLng = projection.fromScreenLocation(focalPoint);
MapState state = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom());
state.setGesture(eventType);
Telemetry.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, state));
CameraPosition cameraPosition = transform.getCameraPosition();
if (cameraPosition != null) {
double zoom = cameraPosition.zoom;
if (isZoomValid(zoom)) {
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));
}
}
}
private boolean isZoomValid(Transform transform) {
if (transform == null) {
return false;
}
double mapZoom = transform.getZoom();
private boolean isZoomValid(double mapZoom) {
return mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM;
}

View File

@@ -218,10 +218,6 @@ final class Transform implements MapView.OnMapChangedListener {
// Zoom in or out
double getZoom() {
return cameraPosition.zoom;
}
double getRawZoom() {
return mapView.getZoom();
}