示例#1
0
 @Override
 public void onFailure(HttpException error, String msg) {
   LogUtil.e(TAG, mUrl + " " + "msg: " + msg + "error:" + error.getMessage());
   onResult(
       new DMSResponse(
           String.valueOf(Api.RESULT_CODE_NETFAIL),
           mContext.getString(R.string.net_error_tips)));
 }
示例#2
0
 @Override
 public void handleHttpException(HttpException error, String msg) {
   System.out.println(
       error.getMessage() + "-----------" + error.getExceptionCode() + "----------" + msg);
 }
示例#3
0
  public static HttpHandler<String> sendMsgImpl(
      String action,
      RequestParams params,
      int method,
      HttpUtils http,
      final int requestId,
      final SuperLogic logic,
      boolean isStream) {
    String url = HOST + action;
    HttpHandler<String> httpHandler = null;
    HttpMethod httpMethod = method == METHOD_GET ? HttpMethod.GET : HttpMethod.POST;
    if (isStream) {

      ResponseStream sendSync;
      try {
        sendSync = http.sendSync(httpMethod, url, params);
        logic.handleHttpResponse("", requestId, sendSync);
      } catch (HttpException e) {
        logic.handleHttpException(e, e.getMessage());
      }
    } else {
      if (method == METHOD_GET) {
        httpHandler =
            http.send(
                httpMethod,
                url,
                new RequestCallBack<String>() {

                  @Override
                  public void onStart() {}

                  @Override
                  public void onFailure(HttpException error, String msg) {
                    AppLog.out(
                        TAG,
                        "返回异常响应:exceptionCode="
                            + error.getExceptionCode()
                            + ";msg="
                            + msg
                            + ";requestId="
                            + requestId,
                        AppLog.LEVEL_INFO);
                    logic.handleHttpException(error, msg);
                  }

                  @Override
                  public void onSuccess(ResponseInfo<String> ri) {
                    AppLog.out(TAG, "返回响应:" + ri.result, AppLog.LEVEL_INFO);
                    logic.handleHttpResponse(ri.result, 0, requestId);
                  }
                });
      } else {
        httpHandler =
            http.send(
                httpMethod,
                url,
                params,
                new RequestCallBack<String>() {

                  @Override
                  public void onStart() {}

                  @Override
                  public void onFailure(HttpException error, String msg) {
                    AppLog.out(
                        TAG,
                        "返回异常响应:exceptionCode="
                            + error.getExceptionCode()
                            + ";msg="
                            + msg
                            + ";requestId="
                            + requestId,
                        AppLog.LEVEL_INFO);
                    logic.handleHttpException(error, msg);
                  }

                  @Override
                  public void onSuccess(ResponseInfo<String> ri) {
                    AppLog.out(TAG, "返回响应:" + ri.result, AppLog.LEVEL_INFO);
                    logic.handleHttpResponse(ri.result, requestId, null);
                  }
                });
      }
    }

    return httpHandler;
  }