From 9fd7219ebb593822cab1dccfc1365f719f78792c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Sun, 14 May 2017 17:25:34 +0300 Subject: [PATCH] [android] Fixed the order of class fields while marshaling/unmarshaling the map object (bookmark) --- .../mapswithme/maps/bookmarks/data/Bookmark.java | 4 ++-- .../mapswithme/maps/bookmarks/data/MapObject.java | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java index df8180b7fa..53baafb886 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java @@ -58,9 +58,9 @@ public class Bookmark extends MapObject dest.writeString(mObjectTitle); } - protected Bookmark(Parcel source) + protected Bookmark(@MapObjectType int type, Parcel source) { - super(source); + super(type, source); mCategoryId = source.readInt(); mBookmarkId = source.readInt(); mIcon = getIconInternal(); diff --git a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java index efcc9a2a2e..3d683f0498 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/MapObject.java @@ -89,13 +89,13 @@ public class MapObject implements Parcelable mBanners = new ArrayList<>(Arrays.asList(banners)); } - protected MapObject(Parcel source) + protected MapObject(@MapObjectType int type, Parcel source) { //noinspection ResourceType this(source.readString(), // MwmName source.readLong(), // MwmVersion source.readInt(), // FeatureId - source.readInt(), // MapObjectType + type, // MapObjectType source.readString(), // Title source.readString(), // SecondaryTitle source.readString(), // Subtitle @@ -268,9 +268,9 @@ public class MapObject implements Parcelable { @MapObjectType int type = source.readInt(); if (type == BOOKMARK) - return new Bookmark(source); + return new Bookmark(type, source); - return new MapObject(source); + return new MapObject(type, source); } @Override @@ -282,11 +282,12 @@ public class MapObject implements Parcelable @Override public void writeToParcel(Parcel dest, int flags) { + // A map object type must be written first, since it's used in readParcel method to distinguish + // what type of object should be read from the parcel. + dest.writeInt(mMapObjectType); dest.writeString(mMwmName); dest.writeLong(mMwmVersion); dest.writeInt(mFeatureIndex); - dest.writeInt(mMapObjectType); // write map object type twice - first int is used to distinguish created object (MapObject or Bookmark) - dest.writeInt(mMapObjectType); dest.writeString(mTitle); dest.writeString(mSecondaryTitle); dest.writeString(mSubtitle);