summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorkevin <kevin.li@mapbox.com>2019-04-16 15:54:24 +0800
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2019-04-18 16:00:12 +0200
commit6ad2103c133aa0f390db21d9896910f50ddeaa96 (patch)
tree93b77e54f647d5a9f714cdbdf77a835dc622fd8d /platform
parentef5b00b8101dae1ded5162dc949a71d0c4d4e2b7 (diff)
downloadqtlocation-mapboxgl-6ad2103c133aa0f390db21d9896910f50ddeaa96.tar.gz
add base class for events
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapBaseEvent.java31
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java23
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java24
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java23
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapState.java8
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadEndEvent.java51
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadStartEvent.java26
7 files changed, 91 insertions, 95 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapBaseEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapBaseEvent.java
new file mode 100644
index 0000000000..d19b74ebc0
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapBaseEvent.java
@@ -0,0 +1,31 @@
+package com.mapbox.mapboxsdk.module.telemetry;
+
+import android.annotation.SuppressLint;
+import android.os.Parcel;
+
+import com.mapbox.android.telemetry.Event;
+
+/**
+ * Base event class for telemetry events.
+ */
+@SuppressLint("ParcelCreator")
+public abstract class MapBaseEvent extends Event {
+ final String event;
+ final String created;
+
+ MapBaseEvent(PhoneState phoneState) {
+ event = getEventName();
+ this.created = phoneState.getCreated();
+ }
+
+ abstract String getEventName();
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java
index e77a9d9e5b..51e38d0430 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java
@@ -1,18 +1,14 @@
package com.mapbox.mapboxsdk.module.telemetry;
import android.annotation.SuppressLint;
-import android.os.Parcel;
-
-import com.mapbox.android.telemetry.Event;
/**
* Event that represents users' gestures on map, for the details of gestures,
* please refer to {@link com.mapbox.mapboxsdk.constants.TelemetryConstants}
*/
@SuppressLint("ParcelCreator")
-class MapClickEvent extends Event {
- private final String event = "map.click";
- private final String created;
+class MapClickEvent extends MapBaseEvent {
+ private static final String EVENT_NAME = "map.click";
private final String gesture;
private final String cellularNetworkType;
private final String carrier;
@@ -25,11 +21,11 @@ class MapClickEvent extends Event {
private final boolean wifi;
MapClickEvent(PhoneState phoneState, MapState mapState) {
+ super(phoneState);
this.gesture = mapState.getGesture();
this.latitude = mapState.getLatitude();
this.longitude = mapState.getLongitude();
this.zoom = mapState.getZoom();
- this.created = phoneState.getCreated();
this.batteryLevel = phoneState.getBatteryLevel();
this.pluggedIn = phoneState.isPluggedIn();
this.cellularNetworkType = phoneState.getCellularNetworkType();
@@ -38,6 +34,11 @@ class MapClickEvent extends Event {
this.wifi = phoneState.isWifi();
}
+ @Override
+ String getEventName() {
+ return EVENT_NAME;
+ }
+
String getCreated() {
return created;
}
@@ -167,12 +168,4 @@ class MapClickEvent extends Event {
+ '}';
}
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java
index 0b9646b462..64bf70f786 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java
@@ -1,17 +1,13 @@
package com.mapbox.mapboxsdk.module.telemetry;
import android.annotation.SuppressLint;
-import android.os.Parcel;
-
-import com.mapbox.android.telemetry.Event;
/**
* When user drag map should send this event.
*/
@SuppressLint("ParcelCreator")
-class MapDragendEvent extends Event {
- private final String event = "map.dragend";
- private final String created;
+class MapDragendEvent extends MapBaseEvent {
+ private static final String EVENT_NAME = "map.dragend";
private final String orientation;
private final String carrier;
private final String cellularNetworkType;
@@ -23,10 +19,10 @@ class MapDragendEvent extends Event {
private final boolean wifi;
MapDragendEvent(PhoneState phoneState, MapState mapState) {
+ super(phoneState);
this.lat = mapState.getLatitude();
this.lng = mapState.getLongitude();
this.zoom = mapState.getZoom();
- this.created = phoneState.getCreated();
this.batteryLevel = phoneState.getBatteryLevel();
this.pluggedIn = phoneState.isPluggedIn();
this.cellularNetworkType = phoneState.getCellularNetworkType();
@@ -35,6 +31,11 @@ class MapDragendEvent extends Event {
this.carrier = phoneState.getCarrier();
}
+ @Override
+ String getEventName() {
+ return EVENT_NAME;
+ }
+
String getCreated() {
return created;
}
@@ -154,13 +155,4 @@ class MapDragendEvent extends Event {
+ ", wifi=" + wifi
+ '}';
}
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- }
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java
index 61bc87da2b..146fb6e49e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapLoadEvent.java
@@ -2,22 +2,19 @@ package com.mapbox.mapboxsdk.module.telemetry;
import android.annotation.SuppressLint;
import android.os.Build;
-import android.os.Parcel;
-import com.mapbox.android.telemetry.Event;
import com.mapbox.mapboxsdk.BuildConfig;
/**
* Event will be sent while map is loaded.
*/
@SuppressLint("ParcelCreator")
-class MapLoadEvent extends Event {
- private final String event = "map.load";
+class MapLoadEvent extends MapBaseEvent {
+ private static final String EVENT_NAME = "map.load";
private final String operatingSystem = "Android - " + Build.VERSION.RELEASE;
private final String sdkIdentifier = BuildConfig.MAPBOX_SDK_IDENTIFIER;
private final String sdkVersion = BuildConfig.MAPBOX_SDK_VERSION;
private final String model = Build.MODEL;
- private final String created;
private final String userId;
private final String carrier;
private final String cellularNetworkType;
@@ -30,7 +27,7 @@ class MapLoadEvent extends Event {
MapLoadEvent(String userId, PhoneState phoneState) {
- this.created = phoneState.getCreated();
+ super(phoneState);
this.userId = userId;
this.batteryLevel = phoneState.getBatteryLevel();
this.pluggedIn = phoneState.isPluggedIn();
@@ -42,6 +39,11 @@ class MapLoadEvent extends Event {
this.orientation = phoneState.getOrientation();
}
+ @Override
+ String getEventName() {
+ return EVENT_NAME;
+ }
+
String getOperatingSystem() {
return operatingSystem;
}
@@ -186,13 +188,4 @@ class MapLoadEvent extends Event {
+ ", wifi=" + wifi
+ '}';
}
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapState.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapState.java
index cb58f8c1a2..ab75ffa994 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapState.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapState.java
@@ -17,14 +17,14 @@ public class MapState {
this.zoom = zoom;
}
- void setGesture(String gesture) {
- this.gesture = gesture;
- }
-
String getGesture() {
return gesture;
}
+ void setGesture(String gesture) {
+ this.gesture = gesture;
+ }
+
double getLatitude() {
return latitude;
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadEndEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadEndEvent.java
index e086d760b7..6a779aacef 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadEndEvent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadEndEvent.java
@@ -1,10 +1,8 @@
package com.mapbox.mapboxsdk.module.telemetry;
import android.annotation.SuppressLint;
-import android.os.Parcel;
import android.support.annotation.FloatRange;
-import com.mapbox.android.telemetry.Event;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.offline.OfflineRegion;
@@ -12,9 +10,8 @@ import com.mapbox.mapboxsdk.offline.OfflineRegion;
* Event will be sent while offline download end.
*/
@SuppressLint("ParcelCreator")
-public class OfflineDownloadEndEvent extends Event {
- private final String event = "map.offlineDownload.end";
- private final String created;
+public class OfflineDownloadEndEvent extends MapBaseEvent {
+ private static final String EVENT_NAME = "map.offlineDownload.end";
private final Double minZoom;
private final Double maxZoom;
private final String shapeForOfflineRegion;
@@ -28,26 +25,15 @@ public class OfflineDownloadEndEvent extends Event {
to = MapboxConstants.MAXIMUM_ZOOM) Double minZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double maxZoom) {
- this.created = phoneState.getCreated();
+ super(phoneState);
this.shapeForOfflineRegion = shapeForOfflineRegion;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
}
- void setStyleURL(String styleURL) {
- this.styleURL = styleURL;
- }
-
- void setSizeOfResourcesCompleted(long sizeOfResourcesCompleted) {
- this.sizeOfResourcesCompleted = sizeOfResourcesCompleted;
- }
-
- void setNumberOfTilesCompleted(long numberOfTilesCompleted) {
- this.numberOfTilesCompleted = numberOfTilesCompleted;
- }
-
- void setState(@OfflineRegion.DownloadState int state) {
- this.state = state;
+ @Override
+ String getEventName() {
+ return EVENT_NAME;
}
String getCreated() {
@@ -70,18 +56,34 @@ public class OfflineDownloadEndEvent extends Event {
return styleURL;
}
+ void setStyleURL(String styleURL) {
+ this.styleURL = styleURL;
+ }
+
long getSizeOfResourcesCompleted() {
return sizeOfResourcesCompleted;
}
+ void setSizeOfResourcesCompleted(long sizeOfResourcesCompleted) {
+ this.sizeOfResourcesCompleted = sizeOfResourcesCompleted;
+ }
+
long getNumberOfTilesCompleted() {
return numberOfTilesCompleted;
}
+ void setNumberOfTilesCompleted(long numberOfTilesCompleted) {
+ this.numberOfTilesCompleted = numberOfTilesCompleted;
+ }
+
int getState() {
return state;
}
+ void setState(@OfflineRegion.DownloadState int state) {
+ this.state = state;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -146,13 +148,4 @@ public class OfflineDownloadEndEvent extends Event {
+ ", state=" + state
+ '}';
}
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- }
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadStartEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadStartEvent.java
index 2900557805..775e453a4f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadStartEvent.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/OfflineDownloadStartEvent.java
@@ -1,19 +1,16 @@
package com.mapbox.mapboxsdk.module.telemetry;
import android.annotation.SuppressLint;
-import android.os.Parcel;
import android.support.annotation.FloatRange;
-import com.mapbox.android.telemetry.Event;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
/**
* Event will be sent while offline download start.
*/
@SuppressLint("ParcelCreator")
-public class OfflineDownloadStartEvent extends Event {
- private final String event = "map.offlineDownload.start";
- private final String created;
+public class OfflineDownloadStartEvent extends MapBaseEvent {
+ private static final String EVENT_NAME = "map.offlineDownload.start";
private final Double minZoom;
private final Double maxZoom;
private final String shapeForOfflineRegion;
@@ -24,14 +21,15 @@ public class OfflineDownloadStartEvent extends Event {
to = MapboxConstants.MAXIMUM_ZOOM) Double minZoom,
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
to = MapboxConstants.MAXIMUM_ZOOM) Double maxZoom) {
- this.created = phoneState.getCreated();
+ super(phoneState);
this.shapeForOfflineRegion = shapeForOfflineRegion;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
}
- void setStyleURL(String styleURL) {
- this.styleURL = styleURL;
+ @Override
+ String getEventName() {
+ return EVENT_NAME;
}
String getCreated() {
@@ -54,6 +52,10 @@ public class OfflineDownloadStartEvent extends Event {
return styleURL;
}
+ void setStyleURL(String styleURL) {
+ this.styleURL = styleURL;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -104,12 +106,4 @@ public class OfflineDownloadStartEvent extends Event {
+ '}';
}
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- }
}