예제 #1
0
  private void destoryFav(String statusId) {
    for (StatusContent status : getAdapter().getDatas()) {
      if (status.getId().equals(statusId)) {
        // 更新ListView
        getAdapter().removeItemAndRefresh(status);

        FavoritesCacheUtility.destory(statusId);
        break;
      }
    }
  }
    @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;
    }