Skip to content

Instantly share code, notes, and snippets.

@shahbazahmed1269
Created May 29, 2017 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahbazahmed1269/d85a967d298b2360a99f770431166687 to your computer and use it in GitHub Desktop.
Save shahbazahmed1269/d85a967d298b2360a99f770431166687 to your computer and use it in GitHub Desktop.
public class IssueRepositoryImpl implements IssueRepository {
public static final String BASE_URL = "https://api.github.com/";
private GithubApiService mApiService;
public IssueRepositoryImpl() {
Retrofit retrofit = new Retrofit.Builder()
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(BASE_URL)
.build();
mApiService = retrofit.create(GithubApiService.class);
}
public LiveData<ApiResponse> getIssues(String owner, String repo) {
final MutableLiveData<ApiResponse> liveData = new MutableLiveData<>();
Call<List<Issue>> call = mApiService.getIssues(owner, repo);
call.enqueue(new Callback<List<Issue>>() {
@Override
public void onResponse(Call<List<Issue>> call, Response<List<Issue>> response) {
liveData.setValue(new ApiResponse(response.body()));
}
@Override
public void onFailure(Call<List<Issue>> call, Throwable t) {
liveData.setValue(new ApiResponse(t));
}
});
return liveData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment