コード例 #1
0
 public static void parseJSON(JSONObject routesJson) throws JSONException {
   JSONArray jRoutes = new JSONArray();
   BusManager sharedManager = BusManager.getBusManager();
   if (routesJson != null)
     jRoutes = routesJson.getJSONObject(BusManager.TAG_DATA).getJSONArray("72");
   for (int j = 0; j < jRoutes.length(); j++) {
     JSONObject routeObject = jRoutes.getJSONObject(j);
     String routeLongName = routeObject.getString(BusManager.TAG_LONG_NAME);
     String routeID = routeObject.getString(BusManager.TAG_ROUTE_ID);
     Route r = sharedManager.getRoute(routeLongName, routeID);
     JSONArray stops = routeObject.getJSONArray(BusManager.TAG_STOPS);
     for (int i = 0; i < stops.length(); i++) {
       r.addStop(i, sharedManager.getStopByID(stops.getString(i)));
     }
     JSONArray segments = routeObject.getJSONArray(BusManager.TAG_SEGMENTS);
     if (BuildConfig.DEBUG)
       Log.v(
           MainActivity.REFACTOR_LOG_TAG,
           "Found " + segments.length() + " segments for route " + routeID);
     for (int i = 0; i < segments.length(); i++) {
       // if (BuildConfig.DEBUG) Log.v("MapDebugging", "parseJSON of Route adding segment ID " +
       // segments.getJSONArray(i).getString(0) + " for " + routeID + "(" +
       // r.getSegmentIDs().size() + " total)");
       r.getSegmentIDs().add(segments.getJSONArray(i).getString(0));
     }
     sharedManager.addRoute(r);
     // if (BuildConfig.DEBUG) Log.v("JSONDebug", "Route name: " + routeLongName + " | ID:" +
     // routeID + " | Number of stops: " + sharedManager.getRouteByID(routeID).getStops().size());
   }
 }
コード例 #2
0
 public Route(String mLongName, String mRouteID) {
   segmentIDs = new ArrayList<>();
   segments = new ArrayList<>();
   longName = mLongName;
   routeID = mRouteID;
   sharedManager = BusManager.getBusManager();
   stops = sharedManager.getStopsByRouteID(routeID);
   for (Stop s : stops) {
     s.addRoute(this);
   }
 }