Example #1
0
    @Override
    public void run() {
      mFeedDownload =
          new HTMLDownloadCommand(
              "http://news.ycombinator.com/", "", RequestType.GET, false, null, App.getInstance());
      mFeedDownload.run();

      if (mCancelled) mErrorCode = IAPICommand.ERROR_CANCELLED_BY_USER;
      else mErrorCode = mFeedDownload.getErrorCode();

      if (!mCancelled && mErrorCode == IAPICommand.ERROR_NONE) {
        HNFeedParser feedParser = new HNFeedParser();
        try {
          mResult = feedParser.parse(mFeedDownload.getResponseContent());
          Run.inBackground(
              new Runnable() {
                public void run() {
                  FileUtil.setLastHNFeed(mResult);
                }
              });
        } catch (Exception e) {
          ExceptionUtil.sendToGoogleAnalytics(e, Const.GAN_ACTION_PARSING);
          Log.e("HNFeedTask", "HNFeed Parser Error :(", e);
        }
      }

      if (mResult == null) mResult = new HNFeed();
    }
Example #2
0
        public void run() {

          List<HNPost> mPosts = mFeed.getPosts();

          HNFeedParser parser = new HNFeedParser();

          for (int i = 0; i < mPosts.size(); i++) {
            HNPost post = mPosts.get(i);
            post.setContent(parser.getURLContent(post.getURL()));
            getURLContent_ThreadHandler.sendEmptyMessage(0);
          }
        }