Search in sources :

Example 1 with CreateMilestone

use of com.meisolsson.githubsdk.model.request.issue.CreateMilestone in project gh4a by slapperwan.

the class IssueMilestoneEditActivity method setMilestoneState.

private void setMilestoneState(boolean open) {
    @StringRes int dialogMessageResId = open ? R.string.opening_msg : R.string.closing_msg;
    String errorMessage = getString(open ? R.string.issue_milestone_reopen_error : R.string.issue_milestone_close_error, mMilestone.title());
    IssueMilestoneService service = ServiceFactory.get(IssueMilestoneService.class, false);
    CreateMilestone request = CreateMilestone.builder().state(open ? IssueState.Open : IssueState.Closed).build();
    service.editMilestone(mRepoOwner, mRepoName, mMilestone.id(), request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, dialogMessageResId, errorMessage)).subscribe(result -> {
        mMilestone = result;
        updateHighlightColor();
        supportInvalidateOptionsMenu();
        setResult(RESULT_OK);
    }, error -> handleActionFailure("Updating milestone failed", error));
}
Also used : IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) StringRes(android.support.annotation.StringRes) CreateMilestone(com.meisolsson.githubsdk.model.request.issue.CreateMilestone) ApiHelpers(com.gh4a.utils.ApiHelpers)

Example 2 with CreateMilestone

use of com.meisolsson.githubsdk.model.request.issue.CreateMilestone in project gh4a by slapperwan.

the class IssueMilestoneEditActivity method saveMilestone.

private void saveMilestone(String title, String desc) {
    String errorMessage = getString(R.string.issue_error_create_milestone, title);
    IssueMilestoneService service = ServiceFactory.get(IssueMilestoneService.class, false);
    CreateMilestone request = CreateMilestone.builder().title(title).description(desc).state(mMilestone.state()).dueOn(mMilestone.dueOn()).build();
    Single<Response<Milestone>> responseSingle = isInEditMode() ? service.editMilestone(mRepoOwner, mRepoName, mMilestone.id(), request) : service.createMilestone(mRepoOwner, mRepoName, request);
    responseSingle.map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.saving_msg, errorMessage)).subscribe(result -> {
        mMilestone = result;
        setResult(RESULT_OK);
        finish();
    }, error -> handleActionFailure("Saving milestone failed", error));
}
Also used : IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) Response(retrofit2.Response) CreateMilestone(com.meisolsson.githubsdk.model.request.issue.CreateMilestone) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)2 CreateMilestone (com.meisolsson.githubsdk.model.request.issue.CreateMilestone)2 IssueMilestoneService (com.meisolsson.githubsdk.service.issues.IssueMilestoneService)2 StringRes (android.support.annotation.StringRes)1 Response (retrofit2.Response)1