Search in sources :

Example 1 with IssueService

use of com.fastaccess.data.service.IssueService in project FastHub by k0shk0sh.

the class IssuePagerPresenter method onLockUnlockIssue.

@Override
public void onLockUnlockIssue(String reason) {
    Issue currentIssue = getIssue();
    if (currentIssue == null)
        return;
    String login = getLogin();
    String repoId = getRepoId();
    int number = currentIssue.getNumber();
    LockIssuePrModel model = null;
    if (!isLocked() && !InputHelper.isEmpty(reason)) {
        model = new LockIssuePrModel(true, reason);
    }
    IssueService issueService = RestProvider.getIssueService(isEnterprise());
    Observable<Response<Boolean>> observable = RxHelper.getObservable(model == null ? issueService.unlockIssue(login, repoId, number) : issueService.lockIssue(model, login, repoId, number));
    makeRestCall(observable, booleanResponse -> {
        int code = booleanResponse.code();
        if (code == 204) {
            issueModel.setLocked(!isLocked());
            sendToView(view -> view.onSetupIssue(true));
        }
        sendToView(IssuePagerMvp.View::hideProgress);
    });
}
Also used : IssueService(com.fastaccess.data.service.IssueService) Response(retrofit2.Response) Issue(com.fastaccess.data.dao.model.Issue) LockIssuePrModel(com.fastaccess.data.dao.LockIssuePrModel)

Example 2 with IssueService

use of com.fastaccess.data.service.IssueService in project FastHub by k0shk0sh.

the class PullRequestPagerPresenter method onLockUnlockConversations.

@Override
public void onLockUnlockConversations(String reason) {
    PullRequest currentPullRequest = getPullRequest();
    if (currentPullRequest == null)
        return;
    IssueService service = RestProvider.getIssueService(isEnterprise());
    LockIssuePrModel model = null;
    if (!isLocked() && !InputHelper.isEmpty(reason)) {
        model = new LockIssuePrModel(true, reason);
    }
    Observable<Response<Boolean>> observable = RxHelper.getObservable(model == null ? service.unlockIssue(login, repoId, issueNumber) : service.lockIssue(model, login, repoId, issueNumber));
    makeRestCall(observable, booleanResponse -> {
        int code = booleanResponse.code();
        if (code == 204) {
            pullRequest.setLocked(!isLocked());
            sendToView(view -> view.onSetupIssue(false));
        }
    });
}
Also used : IssueService(com.fastaccess.data.service.IssueService) Response(retrofit2.Response) PullRequest(com.fastaccess.data.dao.model.PullRequest) LockIssuePrModel(com.fastaccess.data.dao.LockIssuePrModel)

Aggregations

LockIssuePrModel (com.fastaccess.data.dao.LockIssuePrModel)2 IssueService (com.fastaccess.data.service.IssueService)2 Response (retrofit2.Response)2 Issue (com.fastaccess.data.dao.model.Issue)1 PullRequest (com.fastaccess.data.dao.model.PullRequest)1