Fix MapMultiSelectionMenu crash
This commit is contained in:
parent
e99ae6b63b
commit
bbff59a88b
1 changed files with 27 additions and 12 deletions
|
@ -44,16 +44,17 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
this.pointDescription = pointDescription;
|
||||
this.object = object;
|
||||
this.mapActivity = mapActivity;
|
||||
if (mapActivity != null) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.MULTI_LINE);
|
||||
controller.setActive(true);
|
||||
initTitle();
|
||||
}
|
||||
}
|
||||
|
||||
protected void deinit() {
|
||||
controller = null;
|
||||
|
@ -160,7 +161,10 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
private void clearMenu() {
|
||||
clearSelectedObjects();
|
||||
objects.clear();
|
||||
getMapActivity().refreshMap();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects) {
|
||||
|
@ -170,8 +174,11 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
this.latLon = latLon;
|
||||
createCollection(selectedObjects);
|
||||
updateNightMode();
|
||||
MapMultiSelectionMenuFragment.showInstance(getMapActivity());
|
||||
getMapActivity().refreshMap();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
MapMultiSelectionMenuFragment.showInstance(mapActivity);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
|
@ -180,7 +187,12 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
}
|
||||
|
||||
public Fragment getFragmentByTag() {
|
||||
return getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return mapActivity.getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
|
@ -199,9 +211,12 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
public void openContextMenu(@NonNull MenuObject menuObject) {
|
||||
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
|
||||
hide();
|
||||
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
|
||||
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSelectedObjects() {
|
||||
for(IContextMenuProvider p : selectedObjects.values()) {
|
||||
|
|
Loading…
Reference in a new issue