Piece of functionality executed after some asynchronous logic completion. It is designed to be used by - but not limited to,
AsyncTask and remote method invocation, like in sample code listed below. On first example
#handle(Object)method is called transparently by asynchronous task after its execution completion.
AsyncTask<Object> task = new AsyncTask<Object>(callback) {
protected Object handle() throws Throwable {
// asynchronous task logic;
}
// here asynchronous task logic invoke Callback#handle with value returned by above AsyncTask#execute
};
task.start();
WeatherService weatherService = Factory.getInstance("http://hub.bbnet.ro/", WeatherService.class);
weatherService.getCurrentWeather(47.1569, 27.5903, new Callback<Weather>() {
public handle(Weather weather) {
// do something useful with returned weather value
}
});