summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java149
1 files changed, 59 insertions, 90 deletions
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 830617fb72..36c75112f1 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,82 +1,78 @@
package com.mapbox.mapboxsdk.module.telemetry;
-import android.content.Context;
+import android.annotation.SuppressLint;
import android.os.Parcel;
-import android.os.Parcelable;
-import com.google.gson.annotations.SerializedName;
import com.mapbox.android.telemetry.Event;
-import com.mapbox.android.telemetry.TelemetryUtils;
-
-class MapDragendEvent extends Event implements Parcelable {
- private static final String MAP_DRAGEND = "map.dragend";
-
- @SerializedName("event")
- private final String event;
- @SerializedName("created")
- private String created;
- @SerializedName("lat")
- private double latitude;
- @SerializedName("lng")
- private double longitude;
- @SerializedName("zoom")
- private double zoom;
- @SerializedName("orientation")
- private String orientation = null;
- @SerializedName("batteryLevel")
- private int batteryLevel;
- @SerializedName("pluggedIn")
- private Boolean pluggedIn;
- @SerializedName("carrier")
- private String carrier = null;
- @SerializedName("cellularNetworkType")
- private String cellularNetworkType;
- @SerializedName("wifi")
- private Boolean wifi = null;
-
- MapDragendEvent(MapState mapState) {
- this.event = MAP_DRAGEND;
- this.latitude = mapState.getLatitude();
- this.longitude = mapState.getLongitude();
+
+/**
+ * When user drag map should send this event.
+ */
+@SuppressLint("ParcelCreator")
+class MapDragendEvent extends Event {
+ private final String event = "map.dragend";
+ private final String created;
+ private final String orientation;
+ private final String carrier;
+ private final String cellularNetworkType;
+ private final int batteryLevel;
+ private final double lat;
+ private final double lng;
+ private final double zoom;
+ private final boolean pluggedIn;
+ private final boolean wifi;
+
+ MapDragendEvent(PhoneState phoneState, MapState mapState) {
+ this.lat = mapState.getLatitude();
+ this.lng = mapState.getLongitude();
this.zoom = mapState.getZoom();
- this.created = TelemetryUtils.obtainCurrentDate();
- this.batteryLevel = 0;
- this.pluggedIn = false;
- this.cellularNetworkType = "";
+ this.created = phoneState.getCreated();
+ this.batteryLevel = phoneState.getBatteryLevel();
+ this.pluggedIn = phoneState.isPluggedIn();
+ this.cellularNetworkType = phoneState.getCellularNetworkType();
+ this.wifi = phoneState.isWifi();
+ this.orientation = phoneState.getOrientation();
+ this.carrier = phoneState.getCarrier();
+ }
+
+ String getCreated() {
+ return created;
}
- MapDragendEvent setDeviceInfo(Context context) {
- this.batteryLevel = TelemetryUtils.obtainBatteryLevel(context);
- this.pluggedIn = TelemetryUtils.isPluggedIn(context);
- this.cellularNetworkType = TelemetryUtils.obtainCellularNetworkType(context);
- return this;
+ String getOrientation() {
+ return orientation;
}
- void setOrientation(String orientation) {
- this.orientation = orientation;
+ String getCarrier() {
+ return carrier;
}
- void setCarrier(String carrier) {
- this.carrier = carrier;
+ String getCellularNetworkType() {
+ return cellularNetworkType;
}
- void setWifi(boolean wifi) {
- this.wifi = wifi;
+ int getBatteryLevel() {
+ return batteryLevel;
}
- private MapDragendEvent(Parcel in) {
- event = in.readString();
- created = in.readString();
- latitude = in.readDouble();
- longitude = in.readDouble();
- zoom = in.readDouble();
- orientation = in.readString();
- batteryLevel = in.readInt();
- pluggedIn = in.readByte() != 0x00;
- carrier = in.readString();
- cellularNetworkType = in.readString();
- byte wifiVal = in.readByte();
- wifi = wifiVal == 0x02 ? null : wifiVal != 0x00;
+ double getLat() {
+ return lat;
+ }
+
+ double getLng() {
+ return lng;
+ }
+
+ double getZoom() {
+ return zoom;
+ }
+
+ boolean isPluggedIn() {
+ return pluggedIn;
+ }
+
+ boolean isWifi() {
+ return wifi;
}
@Override
@@ -86,32 +82,5 @@ class MapDragendEvent extends Event implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(event);
- dest.writeString(created);
- dest.writeDouble(latitude);
- dest.writeDouble(longitude);
- dest.writeDouble(zoom);
- dest.writeString(orientation);
- dest.writeInt(batteryLevel);
- dest.writeByte((byte) (pluggedIn ? 0x01 : 0x00));
- dest.writeString(carrier);
- dest.writeString(cellularNetworkType);
- if (wifi == null) {
- dest.writeByte((byte) (0x02));
- } else {
- dest.writeByte((byte) (wifi ? 0x01 : 0x00));
- }
}
-
- public static final Creator<MapDragendEvent> CREATOR = new Creator<MapDragendEvent>() {
- @Override
- public MapDragendEvent createFromParcel(Parcel in) {
- return new MapDragendEvent(in);
- }
-
- @Override
- public MapDragendEvent[] newArray(int size) {
- return new MapDragendEvent[size];
- }
- };
} \ No newline at end of file