From dcccb2af9f788ef958f1d437993903c02dd2ec52 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 2 Aug 2017 11:02:01 +0300 Subject: [PATCH] Fix context menu --- .../plus/mapcontextmenu/MapContextMenuFragment.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index ad152e32db..f9f799b4b1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -884,7 +884,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { newMenuTopViewHeight = menuTopViewHeightExcludingTitle + titleHeight + titleButtonHeight + downloadButtonsHeight + titleProgressHeight; dy = Math.max(0, newMenuTopViewHeight - menuTopViewHeight - (newMenuTopShadowAllHeight - menuTopShadowAllHeight)); } else { - menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight; + menuTopViewHeightExcludingTitle = newMenuTopViewHeight - line1.getMeasuredHeight() - line2MeasuredHeight - titleButtonHeight - downloadButtonsHeight - titleProgressHeight; menuTitleTopBottomPadding = (line1.getMeasuredHeight() - line1.getLineCount() * line1.getLineHeight()) + (line2MeasuredHeight - line2LineCount * line2LineHeight); } @@ -1128,8 +1128,13 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { RotatedTileBox box = map.getCurrentRotatedTileBox().copy(); box.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f); box.setZoom(zoom); - int markerMapCenterX = (int) box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); - int markerMapCenterY = (int) box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); + boolean hasMapCenter = mapCenter != null; + int markerMapCenterX = 0; + int markerMapCenterY = 0; + if (hasMapCenter) { + markerMapCenterX = (int) box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); + markerMapCenterY = (int) box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude()); + } float cpyOrig = box.getCenterPixelPoint().y; box.setCenterLocation(0.5f, 0.5f); @@ -1146,7 +1151,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { float origMarkerY = this.origMarkerY + cpyDelta; LatLon latlon; - if (center) { + if (center || !hasMapCenter) { latlon = reqMarkerLocation; } else { latlon = box.getLatLonFromPixel(markerMapCenterX, markerMapCenterY);