예제 #1
0
 /**
  * 读取帖子详情
  *
  * @param post_id
  * @return
  * @throws ApiException
  */
 public Post getPost(int post_id, boolean isRefresh) throws AppException {
   Post post = null;
   String key = "post_" + post_id;
   if (isNetworkConnected() && (!isReadDataCache(key) || isRefresh)) {
     try {
       post = ApiClient.getPostDetail(this, post_id);
       if (post != null) {
         Notice notice = post.getNotice();
         post.setNotice(null);
         post.setCacheKey(key);
         saveObject(post, key);
         post.setNotice(notice);
       }
     } catch (AppException e) {
       post = (Post) readObject(key);
       if (post == null) throw e;
     }
   } else {
     post = (Post) readObject(key);
     if (post == null) post = new Post();
   }
   return post;
 }