Skip to content

Commit

Permalink
show station positions also in textual trip output
Browse files Browse the repository at this point in the history
proposed by @pbeccard
  • Loading branch information
grote committed Aug 14, 2014
1 parent c12a6bf commit 9203f4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<string name="time">Time</string>
<string name="date">Date</string>
<string name="min"> min</string>
<string name="walk">Walk</string>
<string name="position">Position</string>
<string name="destination">Destination</string>
<string name="detail_duration">Duration:</string>
<string name="detail_date">Date:</string>
Expand Down
17 changes: 15 additions & 2 deletions src/de/grobox/liberario/LiberarioUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static public void addWalkingBox(Context context, ViewGroup lineLayout) {
}

static public View getDivider(Context context) {
return (View) LayoutInflater.from(context).inflate(R.layout.divider_horizontal, null);
return LayoutInflater.from(context).inflate(R.layout.divider_horizontal, null);
}


Expand Down Expand Up @@ -147,8 +147,11 @@ static public String tripToString(Context context, Trip trip) {
String str = "";

for(Leg leg : trip.legs) {
String apos = "";

str += DateUtils.getTime(context, leg.departureTime) + " ";
str += leg.departure.name;

if(leg instanceof Trip.Public) {
Trip.Public pub = (Trip.Public) leg;
if(pub.line != null && pub.line.label != null) {
Expand All @@ -157,16 +160,26 @@ static public String tripToString(Context context, Trip trip) {
if(pub.destination != null) str += " → " + pub.destination.uniqueShortName();
str += ")";
}
// show departure position if existing
if(pub.getDeparturePosition() != null) {
str += " - " + context.getString(R.string.position) + ": " + pub.getDeparturePosition().name;
}
// remember arrival position if existing
if(pub.getArrivalPosition() != null) {
apos += " - " + context.getString(R.string.position) + ": " + pub.getArrivalPosition().name;
}
} else if(leg instanceof Trip.Individual) {
Trip.Individual ind = (Trip.Individual) leg;
str += " (Walk ";
str += " (" + context.getString(R.string.walk) + " ";
if(ind.distance > 0) str += ind.distance + context.getResources().getString(R.string.meter) + " ";
if(ind.min > 0) str += ind.min + context.getResources().getString(R.string.min);
str += ")";
}

str += "\n";
str += DateUtils.getTime(context, leg.arrivalTime) + " ";
str += leg.arrival.name;
str += apos;
str += "\n";
str += "\n";
}
Expand Down

0 comments on commit 9203f4d

Please sign in to comment.