summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/module/telemetry/MapDragendEvent.java
blob: 9556a9a524fe85a55770606d985f425569aa9a23 (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
package com.mapbox.mapboxsdk.module.telemetry;

import android.annotation.SuppressLint;

/**
 * When user drag map should send this event.
 */
@SuppressLint("ParcelCreator")
class MapDragendEvent extends MapBaseEvent {
  private static final String EVENT_NAME = "map.dragend";
  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) {
    super(phoneState);
    this.lat = mapState.getLatitude();
    this.lng = mapState.getLongitude();
    this.zoom = mapState.getZoom();
    this.batteryLevel = phoneState.getBatteryLevel();
    this.pluggedIn = phoneState.isPluggedIn();
    this.cellularNetworkType = phoneState.getCellularNetworkType();
    this.wifi = phoneState.isWifi();
    this.orientation = phoneState.getOrientation();
    this.carrier = phoneState.getCarrier();
  }

  @Override
  String getEventName() {
    return EVENT_NAME;
  }

  String getOrientation() {
    return orientation;
  }

  String getCarrier() {
    return carrier;
  }

  String getCellularNetworkType() {
    return cellularNetworkType;
  }

  int getBatteryLevel() {
    return batteryLevel;
  }

  double getLat() {
    return lat;
  }

  double getLng() {
    return lng;
  }

  double getZoom() {
    return zoom;
  }

  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;
    }

    MapDragendEvent that = (MapDragendEvent) o;

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

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

  @Override
  public String toString() {
    return "MapDragendEvent{"
      + ", orientation='" + orientation + '\''
      + ", carrier='" + carrier + '\''
      + ", cellularNetworkType='" + cellularNetworkType + '\''
      + ", batteryLevel=" + batteryLevel
      + ", lat=" + lat
      + ", lng=" + lng
      + ", zoom=" + zoom
      + ", pluggedIn=" + pluggedIn
      + ", wifi=" + wifi
      + '}';
  }
}