diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index f2e0a2caa3..8b9f4ed7b8 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -229,13 +229,17 @@ public class MapContextMenu extends MenuTitleController { public void show() { if (!isVisible()) { - MapContextMenuFragment.showInstance(mapActivity); + if (!MapContextMenuFragment.showInstance(this, mapActivity)) { + active = false; + } } } public void show(LatLon latLon, PointDescription pointDescription, Object object) { if (init(latLon, pointDescription, object)) { - MapContextMenuFragment.showInstance(mapActivity); + if (!MapContextMenuFragment.showInstance(this, mapActivity)) { + active = false; + } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 0dee1e0ef3..1f874d60bf 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -943,22 +943,32 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { return (OsmandApplication) getActivity().getApplication(); } - public static void showInstance(final MapActivity mapActivity) { + public static boolean showInstance(final MapContextMenu menu, final MapActivity mapActivity) { + try { - int slideInAnim = R.anim.slide_in_bottom; - int slideOutAnim = R.anim.slide_out_bottom; + if (menu.getLatLon() == null) { + return false; + } - MapContextMenu menu = mapActivity.getContextMenu(); - if (menu.isExtended()) { - slideInAnim = menu.getSlideInAnimation(); - slideOutAnim = menu.getSlideOutAnimation(); + int slideInAnim = R.anim.slide_in_bottom; + int slideOutAnim = R.anim.slide_out_bottom; + + if (menu.isExtended()) { + slideInAnim = menu.getSlideInAnimation(); + slideOutAnim = menu.getSlideOutAnimation(); + } + + MapContextMenuFragment fragment = new MapContextMenuFragment(); + mapActivity.getSupportFragmentManager().beginTransaction() + .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) + .add(R.id.fragmentContainer, fragment, TAG) + .addToBackStack(TAG).commitAllowingStateLoss(); + + return true; + + } catch (RuntimeException e) { + return false; } - - MapContextMenuFragment fragment = new MapContextMenuFragment(); - mapActivity.getSupportFragmentManager().beginTransaction() - .setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim) - .add(R.id.fragmentContainer, fragment, TAG) - .addToBackStack(TAG).commitAllowingStateLoss(); } //DownloadEvents