T - the response body classpublic abstract class NetworkCallback<T> extends Object implements retrofit2.Callback<T>
Callback's Response and routes the server-provided errors to separate methods| Modifier and Type | Class and Description |
|---|---|
static class |
NetworkCallback.SpecificError
Holds the details of a
NetworkCallback.StNetworkException |
static class |
NetworkCallback.StNetworkException
Describes what type of network error occurred
|
| Constructor and Description |
|---|
NetworkCallback() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
onError(int httpStatusCode,
String errorMessage,
retrofit2.Call<T> call,
Throwable t)
Invoked when:
a network exception occurred talking to the server
an unexpected exception occurred creating the request or processing the response
a generic error occurred
|
void |
onFailure(retrofit2.Call<T> call,
Throwable t) |
void |
onResponse(retrofit2.Call<T> call,
retrofit2.Response<T> response) |
abstract void |
onSpecificError(NetworkCallback.StNetworkException networkException,
int httpStatusCode,
NetworkCallback.SpecificError error,
retrofit2.Call<T> call,
retrofit2.Response<T> response)
Invoked when a 400 or 406 application level failure occurred
|
abstract void |
onSuccess(retrofit2.Call<T> call,
retrofit2.Response<T> response)
Invoked for a successful response
|
public abstract void onSuccess(retrofit2.Call<T> call, retrofit2.Response<T> response)
call - The Callresponse - The Responsepublic abstract void onError(int httpStatusCode,
String errorMessage,
retrofit2.Call<T> call,
Throwable t)
httpStatusCode - The http status codeerrorMessage - An error message for this issuecall - The Callt - The Throwable associated to the issuepublic abstract void onSpecificError(NetworkCallback.StNetworkException networkException, int httpStatusCode, NetworkCallback.SpecificError error, retrofit2.Call<T> call, retrofit2.Response<T> response)
networkException - The failure typehttpStatusCode - The http status codeerror - The failure detailscall - The Callresponse - The Responsepublic final void onResponse(@NonNull retrofit2.Call<T> call, retrofit2.Response<T> response)
onResponse in interface retrofit2.Callback<T>