com.android.volley.NetworkError Java Examples

The following examples show how to use com.android.volley.NetworkError. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestSingletonFactory.java    From Netease with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void onErrorResponse(VolleyError error) {
    error.printStackTrace();
    Log.d("RVA", "error:" + error);

    int errorCode = 0;
    if (error instanceof TimeoutError) {
        errorCode = -7;
    } else if (error instanceof NoConnectionError) {
        errorCode = -1;
    } else if (error instanceof AuthFailureError) {
        errorCode = -6;
    } else if (error instanceof ServerError) {
        errorCode = 0;
    } else if (error instanceof NetworkError) {
        errorCode = -1;
    } else if (error instanceof ParseError) {
        errorCode = -8;
    }
    Toast.makeText(contextHold, ErrorCode.errorCodeMap.get(errorCode), Toast.LENGTH_SHORT).show();
}
 
Example #2
Source File: ContentDownloadService.java    From Hentoid with Apache License 2.0 5 votes vote down vote up
private void onRequestError(VolleyError error, @NonNull ImageFile img, @NonNull DocumentFile dir, @NonNull String backupUrl) {
    // Try with the backup URL, if it exists and if the current image isn't a backup itself
    if (!img.isBackup() && !backupUrl.isEmpty()) {
        tryUsingBackupUrl(img, dir, backupUrl);
        return;
    }

    // If no backup, then process the error
    String statusCode = (error.networkResponse != null) ? error.networkResponse.statusCode + "" : "N/A";
    String message = error.getMessage() + (img.isBackup() ? " (from backup URL)" : "");
    String cause = "";

    if (error instanceof TimeoutError) {
        cause = "Timeout";
    } else if (error instanceof NoConnectionError) {
        cause = "No connection";
    } else if (error instanceof AuthFailureError) { // 403's fall in this category
        cause = "Auth failure";
    } else if (error instanceof ServerError) { // 404's fall in this category
        cause = "Server error";
    } else if (error instanceof NetworkError) {
        cause = "Network error";
    } else if (error instanceof ParseError) {
        cause = "Network parse error";
    }

    Timber.w(error);

    updateImageStatusUri(img, false, "");
    logErrorRecord(img.content.getTargetId(), ErrorType.NETWORKING, img.getUrl(), img.getName(), cause + "; HTTP statusCode=" + statusCode + "; message=" + message);
}
 
Example #3
Source File: NetworkUtil.java    From Airbnb-Android-Google-Map-View with MIT License 2 votes vote down vote up
/**
 * Checks if there's any network problem
 *
 * @param error
 * @return
 */
public static boolean isNetworkProblem(Object error) {
    return (error instanceof NetworkError);
}