I have used Square / Retrofit Restful framework to get data from a Restful service, and it works like a charm, code snippet is like below:
FooService restInterface = new RestAdapter.Builder().setEndpoint(FooService.URL).build().create(FooService.class);
restInterface.getAllFoos(new Callback<FooModel>() {
@Override
public void success(FooModel model, Response response) {
//get a list of Foo instances.
}
updateUI();
}
@Override
public void failure(RetrofitError error) {
//log errors.
}
});
I understand this is an async call, however can I have a spinning icon on the top while retrofit is busy working on the background? In case the network is not available.
Also is it possible to set a timeout so when the time is up, a prompt of options to continue waiting or abort the mission?
I noticed there was something close on this site: Is it possible to show progress bar when upload image via Retrofit 2 , but still couldn't figure it out how to do it. Besides, my requirement might be simpler.