Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/FiveTAPIFetcher.java
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | List<Route> parseArrivalsServerResponse(String JSONresponse, AtomicReference<Result> res){ | ||||
} | } | ||||
} catch (JSONException e) { | } catch (JSONException e) { | ||||
e.printStackTrace(); | e.printStackTrace(); | ||||
res.set(Result.PARSER_ERROR); | res.set(Result.PARSER_ERROR); | ||||
return routes; | return routes; | ||||
} | } | ||||
Collections.sort(routes); | Collections.sort(routes); | ||||
res.set(Result.OK); | res.set(Result.OK); | ||||
valerio.bozzolanUnsubmitted Not Done Inline Actionsvalerio.bozzolan: | |||||
return routes; | return routes; | ||||
} | } | ||||
public List<Route> parseDirectionsFromResponse(String response) throws IllegalArgumentException,JSONException{ | public List<Route> parseDirectionsFromResponse(String response) throws IllegalArgumentException,JSONException{ | ||||
if(response == null || response.length()==0) throw new IllegalArgumentException("Response string is null or void"); | if(response == null || response.equals("null") || response.length()==0) | ||||
throw new IllegalArgumentException("Response string is null or void"); | |||||
ArrayList<Route> routes = new ArrayList<>(10); | ArrayList<Route> routes = new ArrayList<>(10); | ||||
JSONArray lines =new JSONArray(response); | JSONArray lines =new JSONArray(response); | ||||
for(int i=0; i<lines.length();i++){ | for(int i=0; i<lines.length();i++){ | ||||
Route.FestiveInfo festivo = Route.FestiveInfo.UNKNOWN; | Route.FestiveInfo festivo = Route.FestiveInfo.UNKNOWN; | ||||
final JSONObject branchJSON = lines.getJSONObject(i); | final JSONObject branchJSON = lines.getJSONObject(i); | ||||
final int branchid = branchJSON.getInt("branch"); | final int branchid = branchJSON.getInt("branch"); | ||||
String description = branchJSON.getString("description"); | String description = branchJSON.getString("description"); | ||||
if(description.contains(" fittizi")){ | if(description.contains(" fittizi")){ | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |
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