Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/GTTJSONFetcher.java
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public Palina ReadArrivalTimesAll(String stopID, AtomicReference<Result> res) { | ||||
for(i = 0; i < howManyRoutes; i++) { | for(i = 0; i < howManyRoutes; i++) { | ||||
thisroute = json.getJSONObject(i); | thisroute = json.getJSONObject(i); | ||||
routename = thisroute.getString("Linea"); | routename = thisroute.getString("Linea"); | ||||
try { | try { | ||||
bacino = thisroute.getString("Bacino"); | bacino = thisroute.getString("Bacino"); | ||||
} catch (JSONException ignored) { // if "Bacino" gets removed... | } catch (JSONException ignored) { // if "Bacino" gets removed... | ||||
bacino = "U"; | bacino = "U"; | ||||
} | } | ||||
final Route r = new Route(routename, thisroute.getString("Direzione"), | |||||
pos = p.addRoute(routename, thisroute.getString("Direzione"), FiveTNormalizer.decodeType(routename, bacino)); | "", | ||||
FiveTNormalizer.decodeType(routename, bacino)); | |||||
passaggi = thisroute.getJSONArray("PassaggiRT"); | passaggi = thisroute.getJSONArray("PassaggiRT"); | ||||
howManyPassaggi = passaggi.length(); | howManyPassaggi = passaggi.length(); | ||||
for(j = 0; j < howManyPassaggi; j++) { | for(j = 0; j < howManyPassaggi; j++) { | ||||
String mPassaggio = passaggi.getString(j); | String mPassaggio = passaggi.getString(j); | ||||
if (mPassaggio.contains("__")){ | if (mPassaggio.contains("__")){ | ||||
mPassaggio = mPassaggio.replace("_", ""); | mPassaggio = mPassaggio.replace("_", ""); | ||||
} | } | ||||
p.addPassaggio(mPassaggio.concat("*"), Passaggio.Source.GTTJSON, pos); | r.addPassaggio(mPassaggio.concat("*"), Passaggio.Source.GTTJSON); | ||||
} | } | ||||
passaggi = thisroute.getJSONArray("PassaggiPR"); // now the non-real-time ones | passaggi = thisroute.getJSONArray("PassaggiPR"); // now the non-real-time ones | ||||
howManyPassaggi = passaggi.length(); | howManyPassaggi = passaggi.length(); | ||||
for(j = 0; j < howManyPassaggi; j++) { | for(j = 0; j < howManyPassaggi; j++) { | ||||
p.addPassaggio(passaggi.getString(j), Passaggio.Source.GTTJSON, pos); | r.addPassaggio(passaggi.getString(j), Passaggio.Source.GTTJSON); | ||||
} | } | ||||
p.addRoute(r); | |||||
} | } | ||||
} catch (JSONException e) { | } catch (JSONException e) { | ||||
res.set(Result.PARSER_ERROR); | res.set(Result.PARSER_ERROR); | ||||
e.printStackTrace(); | |||||
return p; | return p; | ||||
} | } | ||||
p.sortRoutes(); | p.sortRoutes(); | ||||
res.set(Result.OK); | res.set(Result.OK); | ||||
return p; | return p; | ||||
} | } | ||||
@Override | @Override | ||||
public Passaggio.Source getSourceForFetcher() { | public Passaggio.Source getSourceForFetcher() { | ||||
return Passaggio.Source.GTTJSON; | return Passaggio.Source.GTTJSON; | ||||
} | } | ||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register