Created
May 29, 2017 14:57
-
-
Save shahbazahmed1269/d85a967d298b2360a99f770431166687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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