From fdd41b9929d726336c2693d73b0bb03d97fcb638 Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 14 May 2018 14:06:55 +0300 Subject: [PATCH] fix possible npe --- .../net/osmand/plus/mapcontextmenu/MenuBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java index d5d2adb492..5884302e1f 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuBuilder.java @@ -322,11 +322,13 @@ public class MenuBuilder { } private boolean showLocalTransportRoutes() { - return mapContextMenu.getLocalTransportStopRoutes().size() > 0; + List localTransportRoutes = mapContextMenu.getLocalTransportStopRoutes(); + return localTransportRoutes != null && localTransportRoutes.size() > 0; } private boolean showNearbyTransportRoutes() { - return mapContextMenu.getNearbyTransportStopRoutes().size() > 0; + List nearbyTransportRoutes = mapContextMenu.getNearbyTransportStopRoutes(); + return nearbyTransportRoutes != null && nearbyTransportRoutes.size() > 0; } void onHide() { @@ -756,7 +758,7 @@ public class MenuBuilder { } } - private String getAdjustedRouteRef(String ref) { + private String adjustRouteRef(String ref) { if (ref != null) { int charPos = ref.lastIndexOf(':'); if (charPos != -1) { @@ -807,7 +809,7 @@ public class MenuBuilder { shape.setColor(route.getColor(mapActivity.getMyApplication(), !light)); transportRect.setBackgroundDrawable(shape); - transportRect.setText(getAdjustedRouteRef(route.route.getRef())); + transportRect.setText(adjustRouteRef(route.route.getRef())); baseView.addView(transportRect); LinearLayout infoView = new LinearLayout(view.getContext());