mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 00:08:49 +00:00
Sort departures by time when querying station board (Hafas).
This commit is contained in:
parent
f0a665076a
commit
8895e1695f
2 changed files with 23 additions and 0 deletions
|
@ -715,6 +715,10 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
XmlPullUtil.requireEndDocument(pp);
|
||||
|
||||
// sort departures
|
||||
for (final StationDepartures stationDepartures : result.stationDepartures)
|
||||
Collections.sort(stationDepartures.departures, Departure.TIME_COMPARATOR);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (final XmlPullParserException x)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package de.schildbach.pte.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,16 @@ public final class Departure implements Serializable
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public Date getTime()
|
||||
{
|
||||
if (predictedTime != null)
|
||||
return predictedTime;
|
||||
else if (plannedTime != null)
|
||||
return plannedTime;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -110,4 +121,12 @@ public final class Departure implements Serializable
|
|||
return 0;
|
||||
return o.hashCode();
|
||||
}
|
||||
|
||||
public static final Comparator<Departure> TIME_COMPARATOR = new Comparator<Departure>()
|
||||
{
|
||||
public int compare(final Departure departure0, final Departure departure1)
|
||||
{
|
||||
return departure0.getTime().compareTo(departure1.getTime());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue