Exemplo n.º 1
0
  /**
   * Retrieves a list of all the RouteConfigs for specified Agency and stores the result in a
   * MainModel variable
   */
  public void processAllRouteConfigs() {
    mainView.updateStatus("Address search disabled until Route Configs loaded...");
    try {
      long current = System.currentTimeMillis();
      RouteList routeList = mainModel.getRouteList();
      Map<String, RouteConfig> allRouteConfigs =
          new HashMap<String, RouteConfig>(routeList.getRoutes().size());

      mainView.setupProgressBar(routeList.getRoutes().size());
      int progressLength = 1;

      for (Route route : routeList.getRoutes()) {
        RouteConfig routeConfig = mainModel.getRouteConfig(route);
        allRouteConfigs.put(route.getTag(), routeConfig);
        mainView.updateProgressBar(progressLength++);
        Thread.sleep(1);
      }

      mainModel.setAllRouteConfigs(allRouteConfigs);
      mainView.updateStatus(
          "It took " + (System.currentTimeMillis() - current) + " ms to get all routeConfigs.");
      Thread.sleep(5000);
      mainView.updateStatus(MainView.DEFAULT_STATUS);

    } catch (InterruptedException | ServiceUnavailableException e) {
      e.printStackTrace();
    }
  }