Esempio n. 1
0
 @Override
 public void resultTopAvailable(int status, AbstractDataResult<Base> result) {
   if (status == REQUEST_SUCCESS) {
     MobclickAgent.onEvent(
         mActivity, EventContants.com, EventContants.communicate_topicListSuccess);
     mValues.clear();
     mCallback.clear();
     mValues.addAll(result.values);
     mCallback.refreshTop(result.values);
   } else if (status == REQUEST_FAILED) {
     MobclickAgent.onEvent(mActivity, EventContants.com, EventContants.communicate_topicListFail);
     // 错误处理
     mCallback.refreshTop(null);
     mTxtMessage.setText("");
     Toast.makeText(mActivity, result.message, Toast.LENGTH_SHORT).show();
     ExceptionUtil.catchException(result.error, mActivity);
   }
 }
Esempio n. 2
0
  @Override
  public void resultAvailable(int status, AbstractDataResult<Base> result) {
    if (status == REQUEST_SUCCESS) {
      MobclickAgent.onEvent(
          mActivity, EventContants.com, EventContants.communicate_topicListSuccess);
      mLoading = false;
      if (mMaxItems == 0) mMaxItems = result.maxItems;
      if (result.values.size() == 0) {
        mMaxItems = mValues.size();
        mCallback.showLoading(false);
        return;
      }
      // 去除重复内容
      mValues = com.babytree.apps.comm.util.BabytreeUtil.removeDuplicate(mValues, result.values);
      mCallback.dataLoadedDuplicate(result.values);
    } else if (status == REQUEST_FIRST_SUCCESS) {
      MobclickAgent.onEvent(
          mActivity, EventContants.com, EventContants.communicate_topicListSuccess);
      if (mMaxItems < 1) {
        mActivity.findViewById(R.id.load).setVisibility(View.GONE);
        mActivity.findViewById(R.id.list).setVisibility(View.GONE);
        mActivity.findViewById(R.id.layout_empty).setVisibility(View.VISIBLE);
        mActivity.findViewById(R.id.reload).setVisibility(View.GONE);
      } else {
        mActivity.findViewById(R.id.load).setVisibility(View.GONE);
        mActivity.findViewById(R.id.list).setVisibility(View.VISIBLE);
        mActivity.findViewById(R.id.layout_empty).setVisibility(View.GONE);
        mActivity.findViewById(R.id.reload).setVisibility(View.GONE);
        mLoading = false;
        if (mMaxItems == 0) mMaxItems = result.maxItems;
        if (result.values.size() == 0) {
          mMaxItems = mValues.size();
          mCallback.showLoading(false);
          return;
        }
        mValues.addAll(result.values);
        mCallback.dataLoaded(result.values);
        // mCallback.refreshTop(null);//一定要加,不然刷新后头上有个点击刷新
      }
    } else if (status == REQUEST_FIRST_FAILED) {
      MobclickAgent.onEvent(mActivity, EventContants.com, EventContants.communicate_topicListFail);

      mCallback.refreshTop(null);
      mTxtMessage.setText("");
      // 错误处理
      Toast.makeText(mActivity, result.message, Toast.LENGTH_SHORT).show();
      ExceptionUtil.catchException(result.error, mActivity);
      mActivity.findViewById(R.id.load).setVisibility(View.GONE);
      final View reloadView = mActivity.findViewById(R.id.reload);
      reloadView.setVisibility(View.VISIBLE);
      Button btnReload = (Button) reloadView.findViewById(R.id.btn_reload);
      btnReload.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mActivity.findViewById(R.id.load).setVisibility(View.VISIBLE);
              reloadView.setVisibility(View.GONE);
              new FirstBackgroundTask(ForumHandler.this).execute();
            }
          });
    } else if (status == REQUEST_FAILED) {
      MobclickAgent.onEvent(mActivity, EventContants.com, EventContants.communicate_topicListFail);
      // 错误处理
      Toast.makeText(mActivity, result.message, Toast.LENGTH_SHORT).show();
      ExceptionUtil.catchException(result.error, mActivity);
      mCallback.showLoading(false);
      mCallback.showReloading(true);
      View reloadingView = mCallback.getReloadingView();
      Button btnReload = (Button) reloadingView.findViewById(R.id.btn_reload);
      btnReload.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mCallback.showLoading(true);
              mCallback.showReloading(false);
              new BackgroundTask(ForumHandler.this).execute(mValues.size());
            }
          });
    }
  }
Esempio n. 3
0
  @Override
  public void resultAvailable(int status, AbstractDataResult<Base> result) {
    if (status == REQUEST_SUCCESS) {
      MobclickAgent.onEvent(
          mActivity, EventContants.com, EventContants.communicate_topicListSuccess);
      mLoading = false;
      if (mMaxItems == 0) mMaxItems = result.maxItems;
      if (result.values.size() == 0) {
        mMaxItems = mValues.size();
        mCallback.showLoading(false);
        return;
      }
      mValues.addAll(result.values);
      mCallback.dataLoaded(result.values);
    } else if (status == REQUEST_FIRST_SUCCESS) {
      MobclickAgent.onEvent(
          mActivity, EventContants.com, EventContants.communicate_topicListSuccess);
      mTxtMessage.setText(mName + "(" + mMaxItems + "贴)");
      if (mMaxItems < 1) {
        mActivity.findViewById(R.id.load).setVisibility(View.GONE);
        mActivity.findViewById(R.id.list).setVisibility(View.GONE);
        mActivity.findViewById(R.id.layout_empty).setVisibility(View.VISIBLE);
        mActivity.findViewById(R.id.reload).setVisibility(View.GONE);
      } else {
        mActivity.findViewById(R.id.load).setVisibility(View.GONE);
        mActivity.findViewById(R.id.list).setVisibility(View.VISIBLE);
        mActivity.findViewById(R.id.layout_empty).setVisibility(View.GONE);
        mActivity.findViewById(R.id.reload).setVisibility(View.GONE);
        mLoading = false;
        if (mMaxItems == 0) mMaxItems = result.maxItems;
        if (result.values.size() == 0) {
          mMaxItems = mValues.size();
          mCallback.showLoading(false);
          return;
        }
        mValues.addAll(result.values);
        mCallback.dataLoaded(result.values);
      }
    } else if (status == REQUEST_FIRST_FAILED) {
      MobclickAgent.onEvent(mActivity, EventContants.com, EventContants.communicate_topicListFail);
      // 错误处理
      Toast.makeText(mActivity, result.message, Toast.LENGTH_SHORT).show();
      ExceptionUtil.catchException(result.error, mActivity);
      mActivity.findViewById(R.id.load).setVisibility(View.GONE);

      final View reloadView = mActivity.findViewById(R.id.reload);
      reloadView.setVisibility(View.VISIBLE);
      Button btnReload = (Button) reloadView.findViewById(R.id.btn_reload);
      btnReload.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mActivity.findViewById(R.id.load).setVisibility(View.VISIBLE);
              reloadView.setVisibility(View.GONE);
              new FirstBackgroundTask(DoctorTopicListHandler.this).execute();
            }
          });
    } else if (status == REQUEST_FAILED) {
      MobclickAgent.onEvent(mActivity, EventContants.com, EventContants.communicate_topicListFail);
      // 错误处理
      Toast.makeText(mActivity, result.message, Toast.LENGTH_SHORT).show();
      ExceptionUtil.catchException(result.error, mActivity);
      mCallback.showLoading(false);
      mCallback.showReloading(true);
      View reloadingView = mCallback.getReloadingView();
      // if(!mActivity.isFinishing()){
      // showReloadDialogForBack();
      // }

      Button btnReload = (Button) reloadingView.findViewById(R.id.btn_reload);
      btnReload.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              mCallback.showLoading(true);
              mCallback.showReloading(false);
              new BackgroundTask(DoctorTopicListHandler.this).execute(mValues.size());
            }
          });
    }
  }