Skip to content

Instantly share code, notes, and snippets.

@moizest89
Created August 15, 2017 01:37
Show Gist options
  • Save moizest89/d30fb70c5a0f6238c1cd25720af12c07 to your computer and use it in GitHub Desktop.
Save moizest89/d30fb70c5a0f6238c1cd25720af12c07 to your computer and use it in GitHub Desktop.
public class DataManager {
public void getArticles(final DataManagerCallBacks dataManagerCallBacks){
Call<UserResponse> call = this.apiService.getArticlesList();
call.enqueue(new Callback<UserResponse>() {
@Override
public void onResponse(Call<UserResponse> call, Response<UserResponse> response) {
if(response.isSuccessful()){
UserResponse userResponse = response.body();
dataManagerCallBacks.onSuccess(userResponse);
}else{
}
}
@Override
public void onFailure(Call<UserResponse> call, Throwable t) {
dataManagerCallBacks.onError(t);
}
});
}
public interface DataManagerCallBacks<T>{
void onSuccess( T onSucces);
void onError(Throwable onError);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment