From 6a38b44e5fff8dd8de62e9e40c84fcd67c5f42f9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 2 Feb 2021 23:25:45 +0200 Subject: [PATCH] Fix possible npe --- .../net/osmand/plus/osmedit/DashOsmEditsFragment.java | 6 ++++-- .../net/osmand/plus/osmedit/EditPOIMenuController.java | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java index de5e538554..ddd601731a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/DashOsmEditsFragment.java @@ -28,7 +28,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.*; +import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener; /** * Created by Denis @@ -149,7 +149,9 @@ public class DashOsmEditsFragment extends DashBaseFragment @Override public void authorizationCompleted() { - SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[]{selectedPoint}); + if (selectedPoint != null) { + SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] {selectedPoint}); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java index 3c64fb12d7..877ebae773 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPOIMenuController.java @@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.FragmentManager; import net.osmand.data.PointDescription; import net.osmand.osm.PoiType; @@ -54,16 +55,15 @@ public class EditPOIMenuController extends MenuController { || !Algorithms.isEmpty(settings.USER_NAME.get()) && !Algorithms.isEmpty(settings.USER_PASSWORD.get()); + FragmentManager fragmentManager = activity.getSupportFragmentManager(); if (point instanceof OpenstreetmapPoint) { if (isLogged) { - SendPoiBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), - new OsmPoint[]{getOsmPoint()}); + SendPoiBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point}); } else { - LoginBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), null); + LoginBottomSheetFragment.showInstance(fragmentManager, null); } } else if (point instanceof OsmNotesPoint) { - SendOsmNoteBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), - new OsmPoint[]{getOsmPoint()}); + SendOsmNoteBottomSheetFragment.showInstance(fragmentManager, new OsmPoint[] {point}); } } }