Fix empty transport stop name

This commit is contained in:
PavelRatushny 2017-12-28 12:54:34 +02:00
parent f16f6dcaf8
commit 073463f64a

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -116,15 +117,21 @@ public class TransportRouteController extends MenuController {
@Override @Override
public String getTypeStr() { public String getTypeStr() {
if (transportRoute.refStop != null) { if (transportRoute.refStop != null && !TextUtils.isEmpty(transportRoute.refStop.getName())) {
return transportRoute.refStop.getName(); return transportRoute.refStop.getName();
} else if (transportRoute.stop != null) { } else if (transportRoute.stop != null && !TextUtils.isEmpty(transportRoute.stop.getName())) {
return transportRoute.stop.getName(); return transportRoute.stop.getName();
} else { } else if (!TextUtils.isEmpty(getPointDescription().getTypeName())) {
return getPointDescription().getTypeName(); return getPointDescription().getTypeName();
} else {
return getStopType();
} }
} }
private String getStopType() {
return getMapActivity().getString(transportRoute.getTypeStrRes()) + " " + getMapActivity().getString(R.string.transport_Stop).toLowerCase();
}
@Override @Override
public void onShow() { public void onShow() {
super.onShow(); super.onShow();
@ -215,7 +222,10 @@ public class TransportRouteController extends MenuController {
} }
for (int i = startPosition; i < stops.size(); i++) { for (int i = startPosition; i < stops.size(); i++) {
final TransportStop stop = stops.get(i); final TransportStop stop = stops.get(i);
final String name = useEnglishNames ? stop.getEnName(true) : stop.getName(); String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
if (TextUtils.isEmpty(name)) {
name = getStopType();
}
addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon, addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon,
name, false, false, new OnClickListener() { name, false, false, new OnClickListener() {