blob: 6730278d793faad387e4b13cbd0f17fc57a5efb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package com.mapbox.mapboxsdk.maps;
import android.location.Location;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.services.android.telemetry.MapboxEvent;
import java.util.Hashtable;
/**
* Wrapper class for MapboxEvent
* <p>
* Provides facility methods to use Transform and handle the case that the zoom, required for a telemetry event,
* isn't available yet.
* </p>
*/
class MapboxEventWrapper {
@Nullable
static Hashtable<String, Object> buildMapClickEvent(
@NonNull Location location, @NonNull String gestureId, Transform transform) {
try {
double mapZoom = transform.getZoom();
if (mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM) {
// validate zoom #8057
return MapboxEvent.buildMapClickEvent(location, gestureId, transform.getZoom());
}
} catch (NullPointerException exception) {
// Map/Transform is not ready yet #8650
// returning null is valid, event is ignored.
}
return null;
}
@Nullable
static Hashtable<String, Object> buildMapDragEndEvent(
@NonNull Location location, Transform transform) {
try {
double mapZoom = transform.getZoom();
if (mapZoom >= MapboxConstants.MINIMUM_ZOOM && mapZoom <= MapboxConstants.MAXIMUM_ZOOM) {
// validate zoom #8057
return MapboxEvent.buildMapDragEndEvent(location, transform.getZoom());
}
} catch (NullPointerException exception) {
// Map/Transform is not ready yet #8650
// returning null is valid, event is ignored.
}
return null;
}
@Nullable
static Hashtable<String, Object> buildMapLoadEvent() {
return MapboxEvent.buildMapLoadEvent();
}
}
|