use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class IssueMilestoneEditActivity method deleteMilestone.
private void deleteMilestone() {
IssueMilestoneService service = ServiceFactory.get(IssueMilestoneService.class, false);
service.deleteMilestone(mRepoOwner, mRepoName, mMilestone.number()).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.deleting_msg, R.string.issue_error_delete_milestone)).subscribe(result -> {
setResult(RESULT_OK);
finish();
}, error -> handleActionFailure("Deleting milestone failed", error));
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class PullRequestActivity method updatePullRequestState.
private void updatePullRequestState(boolean open) {
@StringRes int dialogMessageResId = open ? R.string.opening_msg : R.string.closing_msg;
@StringRes int errorMessageResId = open ? R.string.issue_error_reopen : R.string.issue_error_close;
String errorMessage = getString(errorMessageResId, mPullRequest.number());
PullRequestService service = ServiceFactory.get(PullRequestService.class, false);
EditPullRequest request = EditPullRequest.builder().state(open ? ApiHelpers.IssueState.OPEN : ApiHelpers.IssueState.CLOSED).build();
service.editPullRequest(mRepoOwner, mRepoName, mPullRequestNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogMessageResId, errorMessage)).subscribe(result -> {
mPullRequest = result;
handlePullRequestUpdate();
}, error -> handleActionFailure("Updating pull request failed", error));
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class ReleaseInfoActivity method loadBody.
private void loadBody() {
final Single<Optional<String>> htmlSingle;
if (TextUtils.isEmpty(mRelease.body())) {
htmlSingle = Single.just(Optional.absent());
} else {
MarkdownService service = ServiceFactory.get(MarkdownService.class, false);
RequestMarkdown request = RequestMarkdown.builder().context(mRepoOwner + "/" + mRepoName).mode("gfm").text(mRelease.body()).build();
htmlSingle = service.renderMarkdown(request).map(ApiHelpers::throwOnFailure).map(Optional::of);
}
mBodySubscription = htmlSingle.compose(makeLoaderSingle(ID_LOADER_BODY, false)).subscribe(this::fillNotes, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class ReleaseInfoActivity method loadRelease.
private void loadRelease(boolean force) {
RepositoryReleaseService service = ServiceFactory.get(RepositoryReleaseService.class, force);
service.getRelease(mRepoOwner, mRepoName, mReleaseId).map(ApiHelpers::throwOnFailure).compose(makeLoaderSingle(ID_LOADER_RELEASE, force)).subscribe(result -> {
mRelease = result;
handleReleaseReady();
setContentShown(true);
}, this::handleLoadFailure);
}
use of com.gh4a.utils.ApiHelpers in project gh4a by slapperwan.
the class RepositoryActivity method loadRepository.
private void loadRepository(boolean force) {
RepositoryService service = ServiceFactory.get(RepositoryService.class, force);
service.getRepository(mRepoOwner, mRepoName).map(ApiHelpers::throwOnFailure).compose(makeLoaderSingle(ID_LOADER_REPO, force)).subscribe(result -> {
mRepository = result;
updateTitle();
invalidateTabs();
// Apply initial page selection first time the repo is loaded
if (mInitialPage >= PAGE_REPO_OVERVIEW && mInitialPage <= PAGE_ACTIVITY) {
getPager().setCurrentItem(mInitialPage);
mInitialPage = -1;
}
setContentShown(true);
supportInvalidateOptionsMenu();
}, this::handleLoadFailure);
}
Aggregations