public abstract class WvaCallback<T> extends Object implements com.digi.wva.internal.MainThreadOptional
| Constructor and Description |
|---|
WvaCallback() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
onResponse(Throwable error,
T response)
Method to be called upon completion of the call that this callback is associated with.
|
boolean |
runsOnUiThread()
Specifies whether this callback should be executed on the
application's main thread (also called the UI thread), or
if it should be executed on a background thread.
|
static <T> WvaCallback<T> |
wrap(WvaCallback<T> callback,
android.os.Handler uiThread)
Normal library users should not need to call this method.
Used internally by the library to convert a normal callback into one where
onResponse is executed on the main thread. |
public abstract void onResponse(Throwable error, T response)
error - a notable exception encountered during the call, or null if there is noneresponse - the "return value" for this callpublic boolean runsOnUiThread()
If you know a callback does not need to be run on the UI thread, in your WvaCallback, override this method. Here's an example:
makeSomeCall(new WvaCallback() {
@Override
public void runsOnUiThread() {
return false;
}
@Override
public void onResponse(Throwable error, Void response) {
// ...
}
});
runsOnUiThread in interface com.digi.wva.internal.MainThreadOptionalpublic static <T> WvaCallback<T> wrap(WvaCallback<T> callback, android.os.Handler uiThread)
onResponse is executed on the main thread.
If the callback's runsOnUiThread() returns true, returns a new WvaCallback instance
to run callback's onResponse method on the UI thread. Otherwise, if
runsOnUiThread() returns false, this method returns the callback.
uiThread - the main thread handler, to be used when wrapping the callback
to execute on the main threadcallback - the callback to wrap