ErrorPolicyCallback - retrofit common error handling for restful API
api = retrofit.create(GreetingApi.class);
api.getGreeting().enqueue(new ErrorPolicyCallback<GreetingResponse>(
ErrorPolicy.createDialog(MainActivity.this),
ErrorPolicy.createDialog(MainActivity.this)
) {
@Override
public void onSuccessfulStatus(Call<GreetingResponse> call, GreetingResponse response) {
String greeting = response.greeting + " " + response.name + " at " + new Date();
textView.setText(greeting);
}
});
public enum ViewType {
TOAST,
SNACKBAR,
DIALOG,
INVIEW
}
compile 'com.purestation:retrofit-plus:0.0.1'