@Override
    protected StatusContents workInBackground(
        RefreshMode mode, String previousPage, String nextPage, Void... p) throws TaskException {
      Params params = new Params();

      if (mode == RefreshMode.refresh && !TextUtils.isEmpty(previousPage))
        params.addParameter("since_id", previousPage);

      if (mode == RefreshMode.update && !TextUtils.isEmpty(nextPage))
        params.addParameter("max_id", nextPage);

      //			params.addParameter("feature", feature);

      // 不管user_id字段传值什么,都返回登录用户的微博
      if (AppContext.getUser().getIdstr().equals(mUser.getIdstr())) {
        params.addParameter("user_id", mUser.getIdstr());
      } else {
        params.addParameter("screen_name", mUser.getScreen_name());
      }

      params.addParameter("count", String.valueOf(AppSettings.getTimelineCount()));

      StatusContents statusContents =
          SinaSDK.getInstance(AppContext.getToken(), getTaskCacheMode(this))
              .statusesUserTimeLine(params);

      if (mNewUser == null
          && (mUser != null && !mUser.getIdstr().equals(AppContext.getUser().getIdstr()))) {
        mNewUser =
            SinaSDK.getInstance(AppContext.getToken()).userShow(null, mUser.getScreen_name());
        mUser = mNewUser;
        if (mNewUser.getStatus() != null) mUser.getStatus().setUser(mNewUser);
        if (mUser.getStatus() != null
            && statusContents != null
            && (statusContents.getStatuses() == null || statusContents.getStatuses().size() == 0)) {
          List<StatusContent> statusList = new ArrayList<StatusContent>();
          statusList.add(mNewUser.getStatus());
          statusContents.setStatuses(statusList);
        }
      }

      if (statusContents != null
          && statusContents.getStatuses() != null
          && statusContents.getStatuses().size() > 0) {
        for (StatusContent status : statusContents.getStatuses()) status.setUser(mUser);
      }

      return statusContents;
    }
예제 #2
0
    @Override
    protected StatusContents workInBackground(
        RefreshMode mode, String previousPage, String nextPage, Void... params)
        throws TaskException {
      Favorities favorities =
          SinaSDK.getInstance(AppContext.getToken(), getTaskCacheMode(this))
              .favorites(nextPage, String.valueOf(AppSettings.getTimelineCount()));

      StatusContents statusContents = new StatusContents(new ArrayList<StatusContent>());
      for (Favority favority : favorities.getFavorites()) {
        statusContents.getStatuses().add(favority.getStatus());
      }
      statusContents.setCache(favorities.isCache());
      statusContents.setExpired(favorities.expired());

      // 如果是重置数据,就判断新加载的数据是否是全部加载完了
      int total = mode == RefreshMode.reset ? 0 : getAdapter().getCount();
      total += favorities.getFavorites().size();
      if (total >= favorities.getTotal_number()) statusContents.setNoMore(true);

      return statusContents;
    }