com.android.volley.Request.deliverError()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(187)

本文整理了Java中com.android.volley.Request.deliverError方法的一些代码示例,展示了Request.deliverError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.deliverError方法的具体详情如下:
包路径:com.android.volley.Request
类名称:Request
方法名:deliverError

Request.deliverError介绍

[英]Delivers error message to the ErrorListener that the Request was initialized with.
[中]将错误消息传递给初始化请求的ErrorListener。

代码示例

代码示例来源:origin: mcxiaoke/android-volley

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  deliverError_called = true;
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  deliverError_called = true;
}

代码示例来源:origin: mcxiaoke/android-volley

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: chentao0707/SimplifyReader

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: googolmo/OkVolley

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
}

代码示例来源:origin: MewX/light-novel-library_Wenku8_Android

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  deliverError_called = true;
}

代码示例来源:origin: tazimete/android-app-food-delivery-system

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  deliverError_called = true;
}

代码示例来源:origin: chuyangliu/tastysnake

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  deliverError_called = true;
}

代码示例来源:origin: Automattic/android-wordpress-com-rest

@Override
public void deliverError(VolleyError error) {
  super.deliverError(error);
  // Fire OnAuthFailedListener if we receive an invalid token error
  if (error.networkResponse != null && error.networkResponse.statusCode >= 400 && mOnAuthFailedListener != null) {
    String jsonString;
    try {
      jsonString = new String(error.networkResponse.data, HttpHeaderParser.parseCharset(error.networkResponse.headers));
    } catch (UnsupportedEncodingException e) {
      jsonString = "";
    }
    JSONObject responseObject;
    try {
      responseObject = new JSONObject(jsonString);
    } catch (JSONException e) {
      responseObject = new JSONObject();
    }
    String restError = responseObject.optString("error", "");
    if (restError.equals("authorization_required") || restError.equals("invalid_token")) {
      mOnAuthFailedListener.onAuthFailed();
    }
  }
}

代码示例来源:origin: mobnetic/BitcoinChecker

@Override
public void deliverError(VolleyError error) {
  if(error!=null && error.networkResponse!=null) {
    final int statusCode = error.networkResponse.statusCode;
    if(statusCode==HttpURLConnection.HTTP_MOVED_PERM || statusCode==HttpURLConnection.HTTP_MOVED_TEMP) {
      String location = error.networkResponse.headers.get("Location");
      if(location!=null && redirectionCount<MAX_REDIRECTION_COUNT) {
        ++redirectionCount;
        redirectionUrl = location;
        requestQueue.add(this);
        return;
      }
    }
  }
  if(errorListener instanceof ResponseErrorListener)
    ((ResponseErrorListener)errorListener).onErrorResponse(getUrl(), requestHeaders, networkResponse, responseString, error);
  else
    super.deliverError(error);
}

代码示例来源:origin: com.mcxiaoke.volley/library

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: MewX/light-novel-library_Wenku8_Android

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: tazimete/android-app-food-delivery-system

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: jungletian/TitanjumNote

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: panxw/android-volley-manager

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: xuningjack/AndroidNet

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: chuyangliu/tastysnake

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: cat9/EasyVolley

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

代码示例来源:origin: AnandChowdhary/saga-android

@SuppressWarnings("unchecked")
  @Override
  public void run() {
    // If this request has canceled, finish it and don't deliver.
    if (mRequest.isCanceled()) {
      mRequest.finish("canceled-at-delivery");
      return;
    }
    // Deliver a normal response or error, depending.
    if (mResponse.isSuccess()) {
      mRequest.deliverResponse(mResponse.result);
    } else {
      mRequest.deliverError(mResponse.error);
    }
    // If this is an intermediate response, add a marker, otherwise we're done
    // and the request can be finished.
    if (mResponse.intermediate) {
      mRequest.addMarker("intermediate-response");
    } else {
      mRequest.finish("done");
    }
    // If we have been provided a post-delivery runnable, run it.
    if (mRunnable != null) {
      mRunnable.run();
    }
  }
}

相关文章