refactored some code

This commit is contained in:
Chumva 2018-03-05 15:06:49 +02:00
parent c4eec1267c
commit c56c9b3165

View file

@ -42,12 +42,12 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
if (transportStopRoute != null) { if (transportStopRoute != null) {
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text); TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
String routeNumber = transportStopRoute.route.getRef(); String routeNumber = transportStopRoute.route.getRef();
if (routeNumber.length() > 4) {
routeNumber = routeNumber.substring(0, 4);
}
if (routeNumber.contains(":")) { if (routeNumber.contains(":")) {
routeNumber = routeNumber.substring(0, routeNumber.lastIndexOf(':')); routeNumber = routeNumber.substring(0, routeNumber.lastIndexOf(':'));
} }
if (routeNumber.length() > 4) {
routeNumber = routeNumber.substring(0, 4);
}
transportStopRouteTextView.setText(routeNumber); transportStopRouteTextView.setText(routeNumber);
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground(); GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode)); gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));