コード例 #1
0
 @Override
 public void onFailure(
     int statusCode, Header[] headers, String responseString, Throwable throwable) {
   if (!mIsSilent) {
     if (mContext != null) {
       if (Utils.isNetworkConnected(mContext)) {
         ToastUtil.make(mContext).show(R.string.common_toast_connectionnodata);
       } else {
         ToastUtil.make(mContext).show(R.string.common_toast_connectionfailed);
       }
       Log.i("http response", responseString);
       JSONObject errorJsonObject = new JSONObject();
       try {
         errorJsonObject.put("code", "-123789");
         errorJsonObject.put("msg", responseString);
       } catch (JSONException e) {
         e.printStackTrace();
       }
       if (mAsyncHttpResponseHandler != null) {
         mAsyncHttpResponseHandler.onFailure(statusCode, headers, throwable, errorJsonObject);
       } else {
         onFailure(statusCode, headers, throwable, errorJsonObject);
       }
     }
   } else {
     super.onFailure(statusCode, headers, responseString, throwable);
   }
 }
コード例 #2
0
  @Override
  public void onFailure(
      int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {

    Log.i("http result", throwable.toString());

    if (!mIsSilent) {
      if (mContext != null) {
        if (Utils.isNetworkConnected(mContext)) {
          ToastUtil.make(mContext).show(R.string.common_toast_connectionnodata);
        } else {
          ToastUtil.make(mContext).show(R.string.common_toast_connectionfailed);
        }
        if (mAsyncHttpResponseHandler != null) {
          mAsyncHttpResponseHandler.onFailure(statusCode, headers, throwable, errorResponse);
        } else {
          super.onFailure(statusCode, headers, throwable, errorResponse);
        }
      }
    } else {
      super.onFailure(statusCode, headers, throwable, errorResponse);
    }
  }