Exemple #1
0
 private void doExpandCatalog(final NetworkCatalogTree tree) {
   final NetworkItemsLoader loader = NetworkLibrary.Instance().getStoredLoader(tree);
   if (loader != null && loader.canResumeLoading()) {
     doOpenTree(tree);
   } else if (loader != null) {
     loader.setPostRunnable(
         new Runnable() {
           public void run() {
             doLoadCatalog(tree);
           }
         });
   } else {
     doLoadCatalog(tree);
   }
 }
  @Override
  public void runSearch(NetworkItemsLoader loader, String pattern) throws ZLNetworkException {
    final LinkedList<ZLNetworkRequest> requestList = new LinkedList<ZLNetworkRequest>();
    final LinkedList<NetworkOperationData> dataList = new LinkedList<NetworkOperationData>();

    for (INetworkLink link : NetworkLibrary.Instance().activeLinks()) {
      final NetworkOperationData data = link.createOperationData(loader);
      final ZLNetworkRequest request = link.simpleSearchRequest(pattern, data);
      if (request != null && MimeType.APP_ATOM_XML.weakEquals(request.Mime)) {
        dataList.add(data);
        requestList.add(request);
      }
    }

    while (!requestList.isEmpty()) {
      ZLNetworkManager.Instance().perform(requestList);

      requestList.clear();

      if (loader.confirmInterruption()) {
        return;
      }
      for (NetworkOperationData data : dataList) {
        ZLNetworkRequest request = data.resume();
        if (request != null) {
          requestList.add(request);
        }
      }
    }
  }