Ejemplo n.º 1
0
  public boolean addFavoritePost(int nPost) {
    fFeed = getSharedPreferences("DATA", 0);
    if (postJsonArray == null) {
      postJsonArray = new JSONArray();
    }
    HNPost temp = mFeed.getPosts().get(nPost);
    if (!isPostinFavorite(temp.getURL())) {
      // New hnPOST
      JSONObject jsonObject = new JSONObject();
      try {
        jsonObject.put("url", temp.getURL());
        jsonObject.put("title", temp.getTitle());
        jsonObject.put("urlDomain", temp.getURLDomain());
        jsonObject.put("author", temp.getAuthor());
        jsonObject.put("postID", temp.getPostID());
        jsonObject.put("commentsCount", temp.getCommentsCount());
        jsonObject.put("points", temp.getPoints());
        jsonObject.put("upvoteURL", null);
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      // put in jsonArray
      postJsonArray.put(jsonObject);
      fFeed.edit().putString("postData", postJsonArray.toString()).commit();

      favoritePosts.addPost(temp);
      return true;
    }
    return false;
  }
Ejemplo n.º 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);
          }
        }