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

import android.annotation.SuppressLint;
import android.support.annotation.FloatRange;

import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.offline.OfflineRegion;

/**
 * Event will be sent while offline download end.
 */
@SuppressLint("ParcelCreator")
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;
  private String styleURL;
  private String state;
  private long sizeOfResourcesCompleted;
  private long numberOfTilesCompleted;

  OfflineDownloadEndEvent(PhoneState phoneState, String shapeForOfflineRegion,
                          @FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
                            to = MapboxConstants.MAXIMUM_ZOOM) Double minZoom,
                          @FloatRange(from = MapboxConstants.MINIMUM_ZOOM,
                            to = MapboxConstants.MAXIMUM_ZOOM) Double maxZoom) {
    super(phoneState);
    this.shapeForOfflineRegion = shapeForOfflineRegion;
    this.minZoom = minZoom;
    this.maxZoom = maxZoom;
  }

  @Override
  String getEventName() {
    return EVENT_NAME;
  }

  Double getMinZoom() {
    return minZoom;
  }

  Double getMaxZoom() {
    return maxZoom;
  }

  String getShapeForOfflineRegion() {
    return shapeForOfflineRegion;
  }

  String getStyleURL() {
    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;
  }

  String getState() {
    return state;
  }

  void setState(@OfflineRegion.DownloadState int state) {
    this.state = String.valueOf(state);
  }

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

    OfflineDownloadEndEvent that = (OfflineDownloadEndEvent) o;

    if (sizeOfResourcesCompleted != that.sizeOfResourcesCompleted) {
      return false;
    }
    if (numberOfTilesCompleted != that.numberOfTilesCompleted) {
      return false;
    }
    if (minZoom != null ? !minZoom.equals(that.minZoom) : that.minZoom != null) {
      return false;
    }
    if (maxZoom != null ? !maxZoom.equals(that.maxZoom) : that.maxZoom != null) {
      return false;
    }
    if (shapeForOfflineRegion != null ? !shapeForOfflineRegion.equals(that.shapeForOfflineRegion)
      : that.shapeForOfflineRegion != null) {
      return false;
    }
    if (styleURL != null ? !styleURL.equals(that.styleURL) : that.styleURL != null) {
      return false;
    }
    return state != null ? state.equals(that.state) : that.state == null;
  }

  @Override
  public int hashCode() {
    int result = minZoom != null ? minZoom.hashCode() : 0;
    result = 31 * result + (maxZoom != null ? maxZoom.hashCode() : 0);
    result = 31 * result + (shapeForOfflineRegion != null ? shapeForOfflineRegion.hashCode() : 0);
    result = 31 * result + (styleURL != null ? styleURL.hashCode() : 0);
    result = 31 * result + (state != null ? state.hashCode() : 0);
    result = 31 * result + (int) (sizeOfResourcesCompleted ^ (sizeOfResourcesCompleted >>> 32));
    result = 31 * result + (int) (numberOfTilesCompleted ^ (numberOfTilesCompleted >>> 32));
    return result;
  }

  @Override
  public String toString() {
    return "OfflineDownloadEndEvent{"
      + ", minZoom=" + minZoom
      + ", maxZoom=" + maxZoom
      + ", shapeForOfflineRegion='" + shapeForOfflineRegion + '\''
      + ", styleURL='" + styleURL + '\''
      + ", sizeOfResourcesCompleted=" + sizeOfResourcesCompleted
      + ", numberOfTilesCompleted=" + numberOfTilesCompleted
      + ", state=" + state
      + '}';
  }
}