use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class ContentListContainerFragment method loadModuleMap.
private void loadModuleMap() {
RepositoryContentService service = ServiceFactory.get(RepositoryContentService.class, false);
String repoOwner = mRepository.owner().login();
String repoName = mRepository.name();
service.getContents(repoOwner, repoName, ".gitmodules", mSelectedRef).map(ApiHelpers::throwOnFailure).map(Optional::of).compose(RxUtils.mapFailureToValue(HttpURLConnection.HTTP_NOT_FOUND, Optional.<Content>absent())).map(contentOpt -> contentOpt.map(content -> StringUtils.fromBase64(content.content()))).map(this::parseModuleMap).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).compose(mRxLoader.makeSingleTransformer(ID_LOADER_MODULEMAP, true)).subscribe(resultOpt -> {
mGitModuleMap = resultOpt.orNull();
if (mContentListFragment != null) {
mContentListFragment.onSubModuleNamesChanged(getSubModuleNames(mContentListFragment));
}
}, ((BaseActivity) getActivity())::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditIssueCommentActivity method createComment.
@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
int issueNumber = getIntent().getIntExtra("issue", 0);
IssueCommentService service = ServiceFactory.get(IssueCommentService.class, false);
CommentRequest request = CommentRequest.builder().body(body).build();
return service.createIssueComment(repoOwner, repoName, issueNumber, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class CommitDiffViewerActivity method addReaction.
@Override
public Single<Reaction> addReaction(ReactionBar.Item item, String content) {
CommitCommentWrapper comment = (CommitCommentWrapper) item;
final ReactionService service = ServiceFactory.get(ReactionService.class, false);
ReactionRequest request = ReactionRequest.builder().content(content).build();
return service.createCommitCommentReaction(mRepoOwner, mRepoName, comment.comment.id(), request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditPullRequestCommentActivity method editComment.
@Override
protected Single<GitHubCommentBase> editComment(String repoOwner, String repoName, long commentId, String body) {
PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
CommentRequest request = CommentRequest.builder().body(body).build();
return service.editReviewComment(repoOwner, repoName, commentId, request).map(ApiHelpers::throwOnFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class EditPullRequestDiffCommentActivity method createComment.
@Override
protected Single<GitHubCommentBase> createComment(String repoOwner, String repoName, String body, long replyToCommentId) {
Bundle extras = getIntent().getExtras();
int prNumber = extras.getInt("pull_request_number", 0);
PullRequestReviewCommentService service = ServiceFactory.get(PullRequestReviewCommentService.class, false);
CreateReviewComment.Builder builder = CreateReviewComment.builder().body(body);
if (replyToCommentId != 0) {
builder.inReplyTo(replyToCommentId);
} else {
builder.commitId(extras.getString("commit_id")).path(extras.getString("path")).position(extras.getInt("position"));
}
return service.createReviewComment(repoOwner, repoName, prNumber, builder.build()).map(ApiHelpers::throwOnFailure);
}
Aggregations