From ad47ca4483c34b934d5b3397d79f923b1ff72483 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 20 Oct 2017 11:58:52 +0300 Subject: [PATCH 1/2] Fix index out of bounds exceptions --- .../net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java | 3 +++ .../net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 594f8d7723..2c3018cd49 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -55,6 +55,9 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL @Override public void onItemClick(View view) { int pos = recyclerView.getChildAdapterPosition(view); + if (pos == RecyclerView.NO_POSITION) { + return; + } MapMarker marker = adapter.getItem(pos); mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), 15, marker.getPointDescription(mapActivity), true, marker); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java index 3013dabc8b..8368cb8091 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHistoryFragment.java @@ -184,6 +184,9 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel @Override public void onItemClick(View view) { int pos = recyclerView.getChildAdapterPosition(view); + if (pos == RecyclerView.NO_POSITION) { + return; + } Object item = adapter.getItem(pos); if (item instanceof MapMarker) { MapMarker marker = (MapMarker) item; From 74bd9a9d0ebcd1672c13f3814ed9a12f9e95f021 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 20 Oct 2017 12:03:32 +0300 Subject: [PATCH 2/2] Fix NPE --- .../osmand/plus/mapmarkers/MapMarkerSelectionFragment.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java index c1f0dd42d7..5fbf6a084d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkerSelectionFragment.java @@ -72,7 +72,11 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment { LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude()); useCenter = !mapLinked; loc = (useCenter ? mw : myLoc); - heading = useCenter ? -mapRotation : head; + if (useCenter) { + heading = -mapRotation; + } else { + heading = head; + } } } nightMode = !app.getSettings().isLightContent();