diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2017-09-22 17:18:16 +0300 |
---|---|---|
committer | Aleksandr Zatsepin <alexzatsepin@users.noreply.github.com> | 2017-09-22 17:34:37 +0300 |
commit | 3fcca0af422aa35152227b06c142b92eb19ffd1c (patch) | |
tree | 3ac44f1779a8afbba9da03d3d9973c643e37288b | |
parent | c84d12779a03bd9b41a025cd734fe3528afa65fe (diff) |
Fixed crash while getting bookmark icon during deserialization from parcel on Android.beta-1012beta-1011beta-1010
-rw-r--r-- | android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java index 2a446dc023..dbdef85815 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java @@ -38,17 +38,18 @@ public class Bookmark extends MapObject mCategoryId = categoryId; mBookmarkId = bookmarkId; mIcon = getIconInternal(); - initXY(); - } - private void initXY() - { final ParcelablePointD ll = nativeGetXY(mCategoryId, mBookmarkId); mMerX = ll.x; mMerY = ll.y; - setLat(Math.toDegrees(2.0 * Math.atan(Math.exp(Math.toRadians(ll.y))) - Math.PI / 2.0)); - setLon(ll.x); + initXY(); + } + + private void initXY() + { + setLat(Math.toDegrees(2.0 * Math.atan(Math.exp(Math.toRadians(mMerY))) - Math.PI / 2.0)); + setLon(mMerX); } @Override @@ -57,14 +58,22 @@ public class Bookmark extends MapObject super.writeToParcel(dest, flags); dest.writeInt(mCategoryId); dest.writeInt(mBookmarkId); + dest.writeString(mIcon.getType()); + dest.writeDouble(mMerX); + dest.writeDouble(mMerY); } + // Do not use Core while restoring from Parcel! In some cases this constructor is called before + // the App is completely initialized. + // TODO: Method restoreHasCurrentPermission causes this strange behaviour, needs to be investigated. protected Bookmark(@MapObjectType int type, Parcel source) { super(type, source); mCategoryId = source.readInt(); mBookmarkId = source.readInt(); - mIcon = getIconInternal(); + mIcon = BookmarkManager.getIconByType(source.readString()); + mMerX = source.readDouble(); + mMerY = source.readDouble(); initXY(); } |