use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditDiffCommentActivity method editComment.
@Override
protected Single<GitHubCommentBase> editComment(String repoOwner, String repoName, long commentId, String body) {
RepositoryCommentService service = ServiceFactory.get(RepositoryCommentService.class, false);
CommentRequest request = CommentRequest.builder().body(body).build();
return service.editCommitComment(repoOwner, repoName, commentId, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditDiffCommentActivity method createComment.
@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
Bundle extras = getIntent().getExtras();
String commitId = extras.getString("commit_id");
RepositoryCommentService service = ServiceFactory.get(RepositoryCommentService.class, false);
CreateCommitComment request = CreateCommitComment.builder().body(body).path(extras.getString("path")).position(extras.getInt("position")).build();
return service.createCommitComment(repoOwner, repoName, commitId, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditPullRequestCommentActivity method createComment.
@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
int prNumber = getIntent().getIntExtra("pr", 0);
PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
CreateReviewComment request = CreateReviewComment.builder().body(body).inReplyTo(replyToCommentId).build();
return service.createReviewComment(repoOwner, repoName, prNumber, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class FileViewerActivity method loadFile.
private void loadFile(boolean force) {
RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, force);
service.getContents(mRepoOwner, mRepoName, mPath, mRef).map(ApiHelpers::throwOnFailure).map(Optional::of).onErrorResumeNext(error -> {
if (error instanceof ApiRequestException) {
ClientErrorResponse response = ((ApiRequestException) error).getResponse();
List<ClientErrorResponse.FieldError> errors = response != null ? response.errors() : null;
if (errors != null) {
for (ClientErrorResponse.FieldError fe : errors) {
if (fe.reason() == ClientErrorResponse.FieldError.Reason.TooLarge) {
openUnsuitableFileAndFinish();
return Single.just(Optional.absent());
}
}
}
}
return Single.error(error);
}).compose(makeLoaderSingle(ID_LOADER_FILE, force)).subscribe(result -> {
if (result.isPresent()) {
mContent = result.get();
onDataReady();
setContentEmpty(false);
} else {
setContentEmpty(true);
setContentShown(true);
}
}, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers 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);
}
Aggregations