Пример #1
0
 @Override
 public void onErrorResponse(VolleyError error) {
   parameters.result = error.toString();
   Log.d(TAG, "onErrorResponse :" + error.toString());
   parameters.responseCode = error.networkResponse.statusCode;
   if (listener != null) listener.faild(parameters);
 }
Пример #2
0
        @Override
        public void onErrorResponse(VolleyError error) {
          if (error.toString().equals(AUTH_ERROR)) {
            Toast.makeText(mContext, getString(R.string.incorrect_login), Toast.LENGTH_LONG).show();
          } else {
            ErrorDialogFragment errorDialog = ErrorDialogFragment.newInstance(error.toString());
            android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
            errorDialog.show(fragmentManager, "dialog");
          }

          mLoginButton.setEnabled(true);
          mProgressBar.setVisibility(View.INVISIBLE);
        }
Пример #3
0
  private void onRebroadcastResponse(
      boolean successful, Broadcast result, VolleyError error, RebroadcastState state) {

    if (successful) {

      if (!state.rebroadcast) {
        // Delete the rebroadcast broadcast by user. Must be done before we update the
        // broadcast so that we can retrieve rebroadcastId for the old one.
        // This will not finish this activity, because this activity displays the
        // rebroadcasted broadcast instead of the rebroadcast broadcast itself, and this is
        // the desired behavior since it won't surprise user, and user can have the chance
        // to undo it.
        Broadcast broadcast = mBroadcastAdapter.getBroadcast();
        if (broadcast != null && broadcast.rebroadcastId != null) {
          EventBus.getDefault().post(new BroadcastDeletedEvent(broadcast.rebroadcastId));
        }
      }
      EventBus.getDefault().post(new BroadcastUpdatedEvent(result));
      ToastUtils.show(
          state.rebroadcast
              ? R.string.broadcast_rebroadcast_successful
              : R.string.broadcast_unrebroadcast_successful,
          this);

    } else {

      LogUtils.e(error.toString());
      Broadcast broadcast = mBroadcastAdapter.getBroadcast();
      if (broadcast != null) {
        boolean notified = false;
        if (error instanceof ApiError) {
          // Correct our local state if needed.
          ApiError apiError = (ApiError) error;
          Boolean shouldBeRebroadcasted = null;
          if (apiError.code == Codes.RebroadcastBroadcast.ALREADY_REBROADCASTED) {
            shouldBeRebroadcasted = true;
          } else if (apiError.code == Codes.RebroadcastBroadcast.NOT_REBROADCASTED_YET) {
            shouldBeRebroadcasted = false;
          }
          if (shouldBeRebroadcasted != null) {
            broadcast.fixRebroacasted(shouldBeRebroadcasted);
            EventBus.getDefault().post(new BroadcastUpdatedEvent(broadcast));
            notified = true;
          }
        }
        if (!notified) {
          // Must notify changed to reset pending status so that off-screen
          // items will be invalidated.
          mBroadcastAdapter.notifyBroadcastChanged();
        }
      }
      ToastUtils.show(
          getString(
              state.rebroadcast
                  ? R.string.broadcast_rebroadcast_failed_format
                  : R.string.broadcast_unrebroadcast_failed_format,
              ApiError.getErrorString(error, this)),
          this);
    }
  }
Пример #4
0
 @Override
 public void onErrorResponse(VolleyError error) {
   if (handler != null) {
     handler.sendMessage(handler.obtainMessage(errorMsg, error.toString()));
   }
   if (isDismissDialog == true) {
     // UICommonUtil.getInstance(networkManagerContext).dismissDialog();
     CommonProgressDialog.hideProgress();
   }
 }
Пример #5
0
 private void onDeleteBroadcastResponse(boolean successful, Broadcast result, VolleyError error) {
   if (successful) {
     ToastUtils.show(R.string.broadcast_delete_successful, this);
     EventBus.getDefault().post(new BroadcastDeletedEvent(mBroadcastId));
     finish();
   } else {
     LogUtils.e(error.toString());
     ToastUtils.show(
         getString(R.string.broadcast_delete_failed_format, ApiError.getErrorString(error, this)),
         this);
   }
 }
        @Override
        public void onError(VolleyError error) {
          super.onError(error);
          Log.d(TAG, "the response --> " + error.toString());

          showToast("网络连接错误,无法播放!");

          /*
           * mVideoView.setVideoURI(Uri.parse(
           * "http://fx.72zhe.com/static/fx/sample.mp4")); videoUri =
           * "http://fx.72zhe.com/static/fx/sample.mp4";
           */

          // mVideoView.requestFocus();
          // updateShareTVdatabase(videoUri, mVideoView.getCurrentPosition());
          // mVideoView.start();
        }
Пример #7
0
  private void onLikeResponse(
      boolean successful, Broadcast result, VolleyError error, LikeState state) {

    if (successful) {

      EventBus.getDefault().post(new BroadcastUpdatedEvent(result));
      ToastUtils.show(
          state.like ? R.string.broadcast_like_successful : R.string.broadcast_unlike_successful,
          this);

    } else {

      LogUtils.e(error.toString());
      Broadcast broadcast = mBroadcastAdapter.getBroadcast();
      if (broadcast != null) {
        boolean notified = false;
        if (error instanceof ApiError) {
          // Correct our local state if needed.
          ApiError apiError = (ApiError) error;
          Boolean shouldBeLiked = null;
          if (apiError.code == Codes.LikeBroadcast.ALREADY_LIKED) {
            shouldBeLiked = true;
          } else if (apiError.code == Codes.LikeBroadcast.NOT_LIKED_YET) {
            shouldBeLiked = false;
          }
          if (shouldBeLiked != null) {
            broadcast.fixLiked(shouldBeLiked);
            EventBus.getDefault().post(new BroadcastUpdatedEvent(broadcast));
            notified = true;
          }
        }
        if (!notified) {
          // Must notify changed to reset pending status so that off-screen
          // items will be invalidated.
          mBroadcastAdapter.notifyBroadcastChanged();
        }
      }
      ToastUtils.show(
          getString(
              state.like
                  ? R.string.broadcast_like_failed_format
                  : R.string.broadcast_unlike_failed_format,
              ApiError.getErrorString(error, this)),
          this);
    }
  }
Пример #8
0
  private void onLoadBroadcastResponse(
      boolean successful, Broadcast result, VolleyError error, LoadBroadcastState state) {

    if (successful) {
      setBroadcast(result);
    } else {
      LogUtils.e(error.toString());
      ToastUtils.show(ApiError.getErrorString(error, this), this);
    }

    setBroadcastRefreshing(false);
    mLoadingBroadcastOrCommentList = false;

    if (successful && state.loadCommentList) {
      loadCommentList(false);
    }
  }
Пример #9
0
 private void onDeleteCommentResponse(
     boolean successful, Boolean result, VolleyError error, DeleteCommentState state) {
   if (successful) {
     ToastUtils.show(R.string.broadcast_comment_delete_successful, this);
     EventBus.getDefault().post(new BroadcastCommentDeletedEvent(mBroadcastId, state.commentId));
     if (mBroadcastAdapter.hasBroadcast()) {
       Broadcast broadcast = mBroadcastAdapter.getBroadcast();
       --broadcast.commentCount;
       EventBus.getDefault().post(new BroadcastUpdatedEvent(broadcast));
     }
   } else {
     LogUtils.e(error.toString());
     ToastUtils.show(
         getString(
             R.string.broadcast_comment_delete_failed_format,
             ApiError.getErrorString(error, this)),
         this);
   }
 }
Пример #10
0
  private void onSendCommentResponse(boolean successful, Comment result, VolleyError error) {

    if (successful) {
      if (!mCanLoadMoreComments) {
        mCommentAdapter.add(result);
        fixCommentCount();
      } else {
        ToastUtils.show(R.string.broadcast_send_comment_successful, this);
      }
      mBroadcastCommentList.scrollToPosition(mAdapter.getItemCount() - 1);
      mCommentEdit.setText(null);
    } else {
      LogUtils.e(error.toString());
      ToastUtils.show(
          getString(
              R.string.broadcast_send_comment_failed_format, ApiError.getErrorString(error, this)),
          this);
    }

    setSendingComment(false);
  }
Пример #11
0
  private void onLoadCommentListResponse(
      boolean successful, CommentList result, VolleyError error, LoadCommentListState state) {

    if (successful) {
      List<Comment> commentList = result.comments;
      mCanLoadMoreComments = commentList.size() == state.count;
      if (state.loadMore) {
        mCommentAdapter.addAll(commentList);
      } else {
        mCommentAdapter.replace(commentList);
      }
    } else {
      LogUtils.e(error.toString());
      ToastUtils.show(ApiError.getErrorString(error, this), this);
    }

    setCommentsRefreshing(false, state.loadMore);
    mLoadingBroadcastOrCommentList = false;

    if (successful) {
      fixCommentCount();
    }
  }
Пример #12
0
 @Override
 public void deliverError(VolleyError error) {
   Log.e("error", error.toString());
   super.deliverError(error);
 }
Пример #13
0
 @Override
 public void onErrorResponse(VolleyError volleyError) {
   showLongToast(context, volleyError.toString());
 }
Пример #14
0
 @Override
 protected void dataError(VolleyError error) {
   LogTool.e(error.toString());
 }