added method getTransportRefSubstring

This commit is contained in:
Chumva 2018-03-05 15:11:16 +02:00
parent c56c9b3165
commit 50fde687c7

View file

@ -41,14 +41,7 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
TransportStopRoute transportStopRoute = getItem(position);
if (transportStopRoute != null) {
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
String routeNumber = transportStopRoute.route.getRef();
if (routeNumber.contains(":")) {
routeNumber = routeNumber.substring(0, routeNumber.lastIndexOf(':'));
}
if (routeNumber.length() > 4) {
routeNumber = routeNumber.substring(0, 4);
}
transportStopRouteTextView.setText(routeNumber);
transportStopRouteTextView.setText(getTransportRefSubstring(transportStopRoute.route.getRef()));
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
}
@ -65,6 +58,16 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
return convertView;
}
public String getTransportRefSubstring(String ref) {
if (ref.contains(":")) {
ref = ref.substring(0, ref.lastIndexOf(':'));
}
if (ref.length() > 4) {
ref = ref.substring(0, 4);
}
return ref;
}
public interface OnClickListener {
void onClick(int position);
}