Fix possible npe
This commit is contained in:
parent
e0ef5bfe58
commit
37fa051bb9
3 changed files with 15 additions and 4 deletions
|
@ -756,6 +756,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
||||||
Fragment fragment = mapActivity != null
|
Fragment fragment = mapActivity != null
|
||||||
? mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG) : null;
|
? mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG) : null;
|
||||||
|
|
|
@ -186,6 +186,7 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
||||||
return fragment != null;
|
return fragment != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Fragment getFragmentByTag() {
|
public Fragment getFragmentByTag() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.PointF;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.support.annotation.DimenRes;
|
import android.support.annotation.DimenRes;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -32,12 +33,15 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
import net.osmand.plus.quickaction.QuickAction;
|
||||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -381,15 +385,20 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupQuickActionBtnVisibility() {
|
private void setupQuickActionBtnVisibility() {
|
||||||
|
MapContextMenu contextMenu = mapActivity.getContextMenu();
|
||||||
|
MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu();
|
||||||
|
WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment();
|
||||||
|
MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null;
|
||||||
|
Fragment multiMenuFragment = multiSelectionMenu.getFragmentByTag();
|
||||||
boolean hideQuickButton = !isLayerOn ||
|
boolean hideQuickButton = !isLayerOn ||
|
||||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||||
contextMenuLayer.isInGpxDetailsMode() ||
|
contextMenuLayer.isInGpxDetailsMode() ||
|
||||||
measurementToolLayer.isInMeasurementMode() ||
|
measurementToolLayer.isInMeasurementMode() ||
|
||||||
mapMarkersLayer.isInPlanRouteMode() ||
|
mapMarkersLayer.isInPlanRouteMode() ||
|
||||||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
|
contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
|
||||||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
|
contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
|
||||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
|
multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||
|
||||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && !mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isRemoving();
|
multiSelectionMenu.isVisible() && multiMenuFragment != null && !multiMenuFragment.isRemoving();
|
||||||
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue