I am stuck in one implementation. I am developing an Android application, into which I integrated 3rd party SDK (library) and calling its APIs. Function calling of SDK is actually Async calls (WebAPI calls called by the library) which gives a response (success or failure).
Now, I am trying to explain the situation by code.
for (................) {
AsyncAPICall (SuccessListener {
onSuccess() {
for (................) {
AsyncAPICall (SuccessListener {
onSuccess() {
for (................) {
AsyncAPICall (SuccessListener, ErrorListener);
}
}
}, ErrorListener);
}
}
}, ErrorListener);
}
I want notification or callback or be informed by something that all Async calls are completed. Async calls are run in a different thread and due to for loop, many calls will be done simultaneously.
Is there any mechanism which informs me once all Async call received responses or I need to do manually something?
Any help?
@Khushbu Shah, I updated my answer, it changes a bit :) (it's pretty long).
To make sure it's working, I created a stand alone working example and use this API to test: https://jsonplaceholder.typicode.com/posts/1
Solution1: Use when call multiple tasks in sequences, the result of previous tasks is always the input of the next task
Solution2: Use when call multiple tasks in sequences, all results of previous tasks is the input of the final task (for example: after uploading avatar image and cover image, call api to create new user with these image URLs):
AndroidManifest
root build.gradle
app/build.gradle
model
RestPostService.java
By the way, use Rx + Retrofit + Dagger + MVP pattern is a great combine.