I want to use Retrofit 2.1.0 for my next Android project. I would like to use Design Pattern and therefore create separate classes for every REST call i.e
IBalanceServ
Make an interface like this on:
public interface BalanceListener {
void onUserAvailable(User user);
}
In your BalanceRestClient have an instance of it. And in onResponse:
@Override
public void onResponse(Call call, Response response) {
User user = response.body();
listener.onUserAvailable(user);
}
Make your Activity implement BalanceListner:
public class BalanceActivity extends Activity implements BalanceListener {
......
@Override
public void onUserAvailable(User user) {
// update user views here
}
}