Exemplo n.º 1
0
  @Override
  protected Boolean doInBackground(net.dev123.mblog.entity.Status... params) {
    boolean isSuccess = false;
    if (microBlog == null || params == null || params.length != 2) {
      return isSuccess;
    }

    net.dev123.mblog.entity.Status max = params[0];
    net.dev123.mblog.entity.Status since = params[1];

    Paging<net.dev123.mblog.entity.Status> paging = new Paging<net.dev123.mblog.entity.Status>();
    paging.setGlobalMax(max);
    paging.setGlobalSince(since);

    if (paging.moveToNext()) {
      try {
        listStatus = microBlog.getMentions(paging);
      } catch (LibException e) {
        if (Constants.DEBUG) Log.e(TAG, "Task", e);
        resultMsg = ResourceBook.getStatusCodeValue(e.getExceptionCode(), adapter.getContext());
        paging.moveToPrevious();
      } finally {
        ListUtil.truncate(listStatus, paging.getMax(), paging.getSince());
      }
    }
    Util.getResponseCounts(listStatus, microBlog);

    isSuccess = listStatus != null && listStatus.size() > 0;
    if (isSuccess && paging.hasNext()) {
      LocalStatus localStatus = StatusUtil.createDividerStatus(listStatus, account);
      listStatus.add(localStatus);
    }
    return isSuccess;
  }
Exemplo n.º 2
0
  @Override
  protected void onPreExecute() {
    super.onPreExecute();
    if (divider != null) {
      divider.setLoading(true);
    }

    if (GlobalVars.NET_TYPE == NetType.NONE) {
      cancel(true);
      resultMsg =
          ResourceBook.getStatusCodeValue(ExceptionCode.NET_UNCONNECTED, adapter.getContext());
      Toast.makeText(adapter.getContext(), resultMsg, Toast.LENGTH_LONG).show();

      if (divider != null) {
        divider.setLoading(false);
      }
      adapter.notifyDataSetChanged();
    }
  }
Exemplo n.º 3
0
  @Override
  protected void onPostExecute(Boolean result) {
    if (divider != null) {
      divider.setLoading(false);
    }

    if (result) {
      adapter.addCacheToDivider(divider, listStatus);
    } else {
      if (resultMsg != null) {
        Toast.makeText(adapter.getContext(), resultMsg, Toast.LENGTH_LONG).show();
      } else {
        Toast.makeText(adapter.getContext(), R.string.msg_no_divider_data, Toast.LENGTH_LONG)
            .show();
        adapter.remove(divider);
      }

      // 如果没有的话,修改状态
      adapter.notifyDataSetChanged();
    }
  }
Exemplo n.º 4
0
 public MetionsPageDownTask(MentionsListAdapter adapter, LocalStatus divider) {
   this.adapter = adapter;
   this.account = adapter.getAccount();
   this.divider = divider;
   microBlog = GlobalVars.getMicroBlog(account);
 }