Merge pull request #4622 from osmandapp/fix_bugs

Fix index out of bounds exceptions
This commit is contained in:
Alexey 2017-10-20 12:05:57 +03:00 committed by GitHub
commit 4959f1779f
3 changed files with 11 additions and 1 deletions

View file

@ -72,7 +72,11 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude()); LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
useCenter = !mapLinked; useCenter = !mapLinked;
loc = (useCenter ? mw : myLoc); loc = (useCenter ? mw : myLoc);
heading = useCenter ? -mapRotation : head; if (useCenter) {
heading = -mapRotation;
} else {
heading = head;
}
} }
} }
nightMode = !app.getSettings().isLightContent(); nightMode = !app.getSettings().isLightContent();

View file

@ -55,6 +55,9 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
@Override @Override
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = recyclerView.getChildAdapterPosition(view); int pos = recyclerView.getChildAdapterPosition(view);
if (pos == RecyclerView.NO_POSITION) {
return;
}
MapMarker marker = adapter.getItem(pos); MapMarker marker = adapter.getItem(pos);
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
15, marker.getPointDescription(mapActivity), true, marker); 15, marker.getPointDescription(mapActivity), true, marker);

View file

@ -184,6 +184,9 @@ public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHel
@Override @Override
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = recyclerView.getChildAdapterPosition(view); int pos = recyclerView.getChildAdapterPosition(view);
if (pos == RecyclerView.NO_POSITION) {
return;
}
Object item = adapter.getItem(pos); Object item = adapter.getItem(pos);
if (item instanceof MapMarker) { if (item instanceof MapMarker) {
MapMarker marker = (MapMarker) item; MapMarker marker = (MapMarker) item;