blob: 5cc54cd1caf5d130fa8eb27cbb2d02d1961c3995 (
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
|
package com.mapbox.mapboxsdk.annotations;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.geometry.LatLng;
/**
* <p>
* Builder for composing {@link com.mapbox.mapboxsdk.annotations.Marker} objects.
* </p>
* <p/>
* <h3>Example</h3>
* <p/>
* <pre>
* mMapView.addMarker(new MarkerOptions()
* .title("Intersection")
* .snippet("H St NW with 15th St NW")
* .position(new LatLng(38.9002073, -77.03364419)));
* </pre>
*/
public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions> implements Parcelable {
public static final Parcelable.Creator<MarkerOptions> CREATOR
= new Parcelable.Creator<MarkerOptions>() {
public MarkerOptions createFromParcel(Parcel in) {
return new MarkerOptions(in);
}
public MarkerOptions[] newArray(int size) {
return new MarkerOptions[size];
}
};
private MarkerOptions(Parcel in) {
marker = new Marker();
position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
snippet(in.readString());
String iconId = in.readString();
Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
Icon icon = new Icon(iconId, iconBitmap);
icon(icon);
title(in.readString());
}
@Override
public MarkerOptions getThis() {
return this;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(getPosition(), flags);
out.writeString(getSnippet());
out.writeString(getIcon().getId());
out.writeParcelable(getIcon().getBitmap(), flags);
out.writeString(getTitle());
}
private Marker marker;
public MarkerOptions() {
marker = new Marker();
}
/**
* Do not use this method. Used internally by the SDK.
*
* @return Marker The build marker
*/
public Marker getMarker() {
marker.setPosition(position);
marker.setSnippet(snippet);
marker.setTitle(title);
marker.setIcon(icon);
return marker;
}
public LatLng getPosition() {
return position;
}
public String getSnippet() {
return snippet;
}
public String getTitle() {
return title;
}
public Icon getIcon() {
return icon;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MarkerOptions marker = (MarkerOptions) o;
if (getPosition() != null ? !getPosition().equals(marker.getPosition()) : marker.getPosition() != null)
return false;
if (getSnippet() != null ? !getSnippet().equals(marker.getSnippet()) : marker.getSnippet() != null)
return false;
if (getIcon() != null ? !getIcon().equals(marker.getIcon()) : marker.getIcon() != null)
return false;
return !(getTitle() != null ? !getTitle().equals(marker.getTitle()) : marker.getTitle() != null);
}
@Override
public int hashCode() {
int result = 1;
result = 31 * result + (getPosition() != null ? getPosition().hashCode() : 0);
result = 31 * result + (getSnippet() != null ? getSnippet().hashCode() : 0);
result = 31 * result + (getIcon() != null ? getIcon().hashCode() : 0);
result = 31 * result + (getTitle() != null ? getTitle().hashCode() : 0);
return result;
}
}
|