I have a method that calls three(foo1(), foo2(), foo3()) api method inside it and each method is dependant on another method's response. I want to call foo1() and when it get response from api then call the foo2() and so on. I am eleborating the process below :
public class Order{
private String mResponse1 = "";
private String mResponse2 = "";
private String mResponse3 = "";
public boolean CreateOrder(String param1, String param2, String param3)
{
foo1(param1);
// Wait until foo1() get response
if(!mResponse1.IsEmpty())
{
//There is some line of code here then call below method.
foo2(param2);
}
// Wait until foo2() get response
if( !mResponse2.IsEmpty())
{
//There is some line of code here then call below method.
foo3(param3);
}
//There is some line of code here .
return true;
}
private void foo1(String param1)
{
----
----
mResponse1 = //Set api response
}
private void foo2(String param2)
{
----
----
mResponse2 = //Set api response
}
private void foo3(String param3)
{
----
----
mResponse3 = //Set api response
}
}
Now how to acheive the above senario using retrofit asynchronous calling. I can't break method CreateOrder() into three.