summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-03-01 14:15:31 +0100
committerTobrun <tobrun@mapbox.com>2016-03-02 08:21:57 +0100
commit7d0dea8dadb4c5cb6da986bccc55634c26d2a209 (patch)
tree7210e31d49d114a302f7861b8d7a364a3326fe6d /platform
parent9346a6d038ee24b6cfd0bd39e311b5e00673c06e (diff)
downloadqtlocation-mapboxgl-7d0dea8dadb4c5cb6da986bccc55634c26d2a209.tar.gz
[android] #4157 - handle null icon when using parceable on MarkerOptions
Diffstat (limited to 'platform')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
index 5cc54cd1ca..a3df23d96f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
@@ -39,10 +39,14 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions
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);
+
+ if(in.readByte()!=0){
+ // this means we have an icon
+ String iconId = in.readString();
+ Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
+ Icon icon = new Icon(iconId, iconBitmap);
+ icon(icon);
+ }
title(in.readString());
}
@@ -53,15 +57,19 @@ public final class MarkerOptions extends BaseMarkerOptions<Marker, MarkerOptions
@Override
public int describeContents() {
- return 0;
+ return hashCode();
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeParcelable(getPosition(), flags);
out.writeString(getSnippet());
- out.writeString(getIcon().getId());
- out.writeParcelable(getIcon().getBitmap(), flags);
+ Icon icon = getIcon();
+ out.writeByte((byte) (icon != null ? 1 : 0));
+ if (icon != null) {
+ out.writeString(getIcon().getId());
+ out.writeParcelable(getIcon().getBitmap(), flags);
+ }
out.writeString(getTitle());
}