Пример #1
0
  /**
   * Downloads a feed
   *
   * @param context The application's environment.
   * @param feed Feed to download
   * @param loadAllPages Set to true to download all pages
   */
  public synchronized void downloadFeed(Context context, Feed feed, boolean loadAllPages)
      throws DownloadRequestException {
    if (feedFileValid(feed)) {
      String username =
          (feed.getPreferences() != null) ? feed.getPreferences().getUsername() : null;
      String password =
          (feed.getPreferences() != null) ? feed.getPreferences().getPassword() : null;
      long ifModifiedSince = feed.isPaged() ? 0 : feed.getLastUpdate().getTime();

      Bundle args = new Bundle();
      args.putInt(REQUEST_ARG_PAGE_NR, feed.getPageNr());
      args.putBoolean(REQUEST_ARG_LOAD_ALL_PAGES, loadAllPages);

      download(
          context,
          feed,
          null,
          new File(getFeedfilePath(context), getFeedfileName(feed)),
          true,
          username,
          password,
          ifModifiedSince,
          true,
          args);
    }
  }
Пример #2
0
  public synchronized void downloadMedia(Context context, FeedMedia feedmedia)
      throws DownloadRequestException {
    if (feedFileValid(feedmedia)) {
      Feed feed = feedmedia.getItem().getFeed();
      String username;
      String password;
      if (feed != null && feed.getPreferences() != null) {
        username = feed.getPreferences().getUsername();
        password = feed.getPreferences().getPassword();
      } else {
        username = null;
        password = null;
      }

      File dest;
      if (feedmedia.getFile_url() != null) {
        dest = new File(feedmedia.getFile_url());
      } else {
        dest = new File(getMediafilePath(context, feedmedia), getMediafilename(feedmedia));
      }
      download(context, feedmedia, feed, dest, false, username, password, 0, false, null);
    }
  }