Multiple callbacks
I need to call the function with callback.
The method asks the server for answer and returns it to the callback.
But I need to send next request to the server.
How can I re-returns the callback from inner method to main callback?
void getListOfRSSItems(final String url, final ResponseListener listener) {
Requester.send(url, new Requester.RequestResponseListener() {
@Override
public void onRequestResponse(HttpResponse response) {
ArrayList<RSSItem> list = getListFromResponse(response);
for (int i = 0; i < list.size(); i++) {
Requester.send(list.get(i).link, new
Requester.RequestResponseListener() {
@Override
public void onRequestResponse(HttpResponse response2) {
// add content to rss item
}
});
list.set(i, // returned rss item);
}
listener.onResponse(list);
}
});
}
and how can I return the rss item to the list and return it over listener?
This doesnt wait to add content code and returns the list of RSSItems
without content.
Can you help me?
Thank you
No comments:
Post a Comment