Search in sources :

Example 6 with IssueMilestoneService

use of com.meisolsson.githubsdk.service.issues.IssueMilestoneService 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

IssueMilestoneService (com.meisolsson.githubsdk.service.issues.IssueMilestoneService)6 ApiHelpers (com.gh4a.utils.ApiHelpers)5 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 Nullable (android.support.annotation.Nullable)2 StringRes (android.support.annotation.StringRes)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)2 AlertDialog (android.support.v7.app.AlertDialog)2 View (android.view.View)2 Gh4Application (com.gh4a.Gh4Application)2 R (com.gh4a.R)2 ServiceFactory (com.gh4a.ServiceFactory)2 RxUtils (com.gh4a.utils.RxUtils)2 SingleFactory (com.gh4a.utils.SingleFactory)2 UiUtils (com.gh4a.utils.UiUtils)2 Issue (com.meisolsson.githubsdk.model.Issue)2 IssueState (com.meisolsson.githubsdk.model.IssueState)2