use of com.meisolsson.githubsdk.service.repositories.RepositoryCommitService in project gh4a by slapperwan.
the class CommitActivity method loadCommit.
private void loadCommit(boolean force) {
RepositoryCommitService service = ServiceFactory.get(RepositoryCommitService.class, force);
service.getCommit(mRepoOwner, mRepoName, mObjectSha).map(ApiHelpers::throwOnFailure).compose(makeLoaderSingle(ID_LOADER_COMMIT, force)).subscribe(result -> {
mCommit = result;
showContentIfReady();
}, this::handleLoadFailure);
}
use of com.meisolsson.githubsdk.service.repositories.RepositoryCommitService in project gh4a by slapperwan.
the class CommitCommentLoadTask method load.
public static Single<Optional<Intent>> load(Context context, String repoOwner, String repoName, String commitSha, IntentUtils.InitialCommentMarker marker) {
RepositoryCommitService commitService = ServiceFactory.get(RepositoryCommitService.class, false);
RepositoryCommentService commentService = ServiceFactory.get(RepositoryCommentService.class, false);
Single<Commit> commitSingle = commitService.getCommit(repoOwner, repoName, commitSha).map(ApiHelpers::throwOnFailure);
Single<List<GitComment>> commentSingle = ApiHelpers.PageIterator.toSingle(page -> commentService.getCommitComments(repoOwner, repoName, commitSha, page)).cache();
Single<Optional<GitHubFile>> fileSingle = commentSingle.compose(RxUtils.filterAndMapToFirst(c -> marker.matches(c.id(), c.createdAt()))).zipWith(commitSingle, (comment, commit) -> {
if (comment.isPresent()) {
for (GitHubFile commitFile : commit.files()) {
if (commitFile.filename().equals(comment.get().path())) {
return Optional.of(commitFile);
}
}
}
return Optional.absent();
});
return Single.zip(commitSingle, commentSingle, fileSingle, (commit, comments, fileOpt) -> {
GitHubFile file = fileOpt.orNull();
if (file != null && !FileUtils.isImage(file.filename())) {
return Optional.of(CommitDiffViewerActivity.makeIntent(context, repoOwner, repoName, commitSha, file.filename(), file.patch(), comments, -1, -1, false, marker));
} else if (file == null) {
return Optional.of(CommitActivity.makeIntent(context, repoOwner, repoName, commitSha, marker));
}
return Optional.absent();
});
}
use of com.meisolsson.githubsdk.service.repositories.RepositoryCommitService in project gh4a by slapperwan.
the class CommitCompareFragment method onCreateDataSingle.
@Override
protected Single<List<Commit>> onCreateDataSingle(boolean bypassCache) {
RepositoryCommitService service = ServiceFactory.get(RepositoryCommitService.class, bypassCache);
Single<CommitCompare> compareSingle = service.compareCommits(mRepoOwner, mRepoName, mBase, mHead).map(ApiHelpers::throwOnFailure).onErrorResumeNext(error -> {
if (error instanceof ApiRequestException) {
ApiRequestException are = (ApiRequestException) error;
if (are.getStatus() == HttpURLConnection.HTTP_NOT_FOUND && mBaseLabel != null && mHeadLabel != null) {
// We got a 404; likely the history of the base branch was rewritten. Try the labels.
return service.compareCommits(mRepoOwner, mRepoName, mBaseLabel, mHeadLabel).map(ApiHelpers::throwOnFailure);
}
}
return Single.error(error);
});
return compareSingle.map(CommitCompare::commits).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, new ArrayList<>()));
}
Aggregations