Merge pull request #5102 from osmandapp/TransportStopRoutesGrid

set length of text in gridview items
This commit is contained in:
Alexey 2018-03-05 17:15:32 +03:00 committed by GitHub
commit 17f27d6cce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,7 +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);
transportStopRouteTextView.setText(transportStopRoute.route.getRef());
transportStopRouteTextView.setText(getAdjustedRouteRef(transportStopRoute.route.getRef()));
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
}
@ -58,6 +58,19 @@ public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute>
return convertView;
}
private String getAdjustedRouteRef(String ref) {
if (ref != null) {
int charPos = ref.lastIndexOf(':');
if (charPos != -1) {
ref = ref.substring(0, charPos);
}
if (ref.length() > 4) {
ref = ref.substring(0, 4);
}
}
return ref;
}
public interface OnClickListener {
void onClick(int position);
}