Navitia: Fix query context builder.

This commit is contained in:
Antonio El Khoury 2015-02-01 22:28:39 +01:00 committed by Andreas Schildbach
parent e86fdede13
commit 8dce62c1ab

View file

@ -1077,11 +1077,22 @@ public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider
else else
{ {
// Fill context. // Fill context.
String prevQueryUri = null;
String nextQueryUri = null;
final JSONArray links = head.getJSONArray("links"); final JSONArray links = head.getJSONArray("links");
final JSONObject prev = links.getJSONObject(0); for (int i = 0; i < links.length(); ++i)
final String prevQueryUri = prev.getString("href"); {
final JSONObject next = links.getJSONObject(1); final JSONObject link = links.getJSONObject(i);
final String nextQueryUri = next.getString("href"); final String type = link.getString("type");
if (type.equals("prev"))
{
prevQueryUri = link.getString("href");
}
else if (type.equals("next"))
{
nextQueryUri = link.getString("href");
}
}
final QueryTripsResult result = new QueryTripsResult(resultHeader, queryUri.toString(), from, null, to, new Context(from, to, final QueryTripsResult result = new QueryTripsResult(resultHeader, queryUri.toString(), from, null, to, new Context(from, to,
prevQueryUri, nextQueryUri), new LinkedList<Trip>()); prevQueryUri, nextQueryUri), new LinkedList<Trip>());