summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapClickEvent.java
blob: 51e38d04300536e8a33069d13b2fc378e75be23c (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package com.mapbox.mapboxsdk.module.telemetry;

import android.annotation.SuppressLint;

/**
 * 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 MapBaseEvent {
  private static final String EVENT_NAME = "map.click";
  private final String gesture;
  private final String cellularNetworkType;
  private final String carrier;
  private final String orientation;
  private final double latitude;
  private final double longitude;
  private final double zoom;
  private final int batteryLevel;
  private final boolean pluggedIn;
  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.batteryLevel = phoneState.getBatteryLevel();
    this.pluggedIn = phoneState.isPluggedIn();
    this.cellularNetworkType = phoneState.getCellularNetworkType();
    this.orientation = phoneState.getOrientation();
    this.carrier = phoneState.getCarrier();
    this.wifi = phoneState.isWifi();
  }

  @Override
  String getEventName() {
    return EVENT_NAME;
  }

  String getCreated() {
    return created;
  }

  String getGesture() {
    return gesture;
  }

  String getCellularNetworkType() {
    return cellularNetworkType;
  }

  String getCarrier() {
    return carrier;
  }

  String getOrientation() {
    return orientation;
  }

  double getLatitude() {
    return latitude;
  }

  double getLongitude() {
    return longitude;
  }

  double getZoom() {
    return zoom;
  }

  int getBatteryLevel() {
    return batteryLevel;
  }

  boolean isPluggedIn() {
    return pluggedIn;
  }

  boolean isWifi() {
    return wifi;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    MapClickEvent that = (MapClickEvent) o;

    if (Double.compare(that.latitude, latitude) != 0) {
      return false;
    }
    if (Double.compare(that.longitude, longitude) != 0) {
      return false;
    }
    if (Double.compare(that.zoom, zoom) != 0) {
      return false;
    }
    if (batteryLevel != that.batteryLevel) {
      return false;
    }
    if (pluggedIn != that.pluggedIn) {
      return false;
    }
    if (wifi != that.wifi) {
      return false;
    }
    if (created != null ? !created.equals(that.created) : that.created != null) {
      return false;
    }
    if (gesture != null ? !gesture.equals(that.gesture) : that.gesture != null) {
      return false;
    }
    if (cellularNetworkType != null ? !cellularNetworkType.equals(that.cellularNetworkType) :
      that.cellularNetworkType != null) {
      return false;
    }
    if (carrier != null ? !carrier.equals(that.carrier) : that.carrier != null) {
      return false;
    }
    return orientation != null ? orientation.equals(that.orientation) : that.orientation == null;
  }

  @Override
  public int hashCode() {
    int result;
    long temp;
    result = event.hashCode();
    result = 31 * result + (created != null ? created.hashCode() : 0);
    result = 31 * result + (gesture != null ? gesture.hashCode() : 0);
    result = 31 * result + (cellularNetworkType != null ? cellularNetworkType.hashCode() : 0);
    result = 31 * result + (carrier != null ? carrier.hashCode() : 0);
    result = 31 * result + (orientation != null ? orientation.hashCode() : 0);
    temp = Double.doubleToLongBits(latitude);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(longitude);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    temp = Double.doubleToLongBits(zoom);
    result = 31 * result + (int) (temp ^ (temp >>> 32));
    result = 31 * result + batteryLevel;
    result = 31 * result + (pluggedIn ? 1 : 0);
    result = 31 * result + (wifi ? 1 : 0);
    return result;
  }

  @Override
  public String toString() {
    return "MapClickEvent{"
      + "event='" + event + '\''
      + ", created='" + created + '\''
      + ", gesture='" + gesture + '\''
      + ", cellularNetworkType='" + cellularNetworkType + '\''
      + ", carrier='" + carrier + '\''
      + ", orientation='" + orientation + '\''
      + ", latitude=" + latitude
      + ", longitude=" + longitude
      + ", zoom=" + zoom
      + ", batteryLevel=" + batteryLevel
      + ", pluggedIn=" + pluggedIn
      + ", wifi=" + wifi
      + '}';
  }

}