Search in sources :

Example 1 with ApiHelpers

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));
}
Also used : IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 2 with ApiHelpers

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));
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) EditPullRequest(com.meisolsson.githubsdk.model.request.pull_request.EditPullRequest) StringRes(android.support.annotation.StringRes) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 3 with ApiHelpers

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);
}
Also used : RequestMarkdown(com.meisolsson.githubsdk.model.request.RequestMarkdown) Optional(com.gh4a.utils.Optional) ApiHelpers(com.gh4a.utils.ApiHelpers) MarkdownService(com.meisolsson.githubsdk.service.misc.MarkdownService)

Example 4 with ApiHelpers

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);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryReleaseService(com.meisolsson.githubsdk.service.repositories.RepositoryReleaseService)

Example 5 with ApiHelpers

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);
}
Also used : ApiHelpers(com.gh4a.utils.ApiHelpers) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)68 Response (retrofit2.Response)13 RxUtils (com.gh4a.utils.RxUtils)12 ServiceFactory (com.gh4a.ServiceFactory)11 Intent (android.content.Intent)10 Bundle (android.os.Bundle)10 Optional (com.gh4a.utils.Optional)10 PullRequestReviewCommentService (com.meisolsson.githubsdk.service.pull_request.PullRequestReviewCommentService)10 Single (io.reactivex.Single)9 Context (android.content.Context)7 LayoutInflater (android.view.LayoutInflater)7 CommentRequest (com.meisolsson.githubsdk.model.request.CommentRequest)7 List (java.util.List)7 View (android.view.View)6 R (com.gh4a.R)6 IntentUtils (com.gh4a.utils.IntentUtils)6 User (com.meisolsson.githubsdk.model.User)6 ReactionRequest (com.meisolsson.githubsdk.model.request.ReactionRequest)6 CreateReviewComment (com.meisolsson.githubsdk.model.request.pull_request.CreateReviewComment)6 ReactionService (com.meisolsson.githubsdk.service.reactions.ReactionService)6