add base class for events
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user