use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class PullRequestPagerActivity method addPrReview.
private void addPrReview(@NonNull View view) {
PullRequest pullRequest = getPresenter().getPullRequest();
if (pullRequest == null)
return;
User author = pullRequest.getUser() != null ? pullRequest.getUser() : pullRequest.getHead() != null && pullRequest.getHead().getAuthor() != null ? pullRequest.getHead().getAuthor() : pullRequest.getUser();
if (author == null)
return;
ReviewRequestModel requestModel = new ReviewRequestModel();
requestModel.setComments(getPresenter().getCommitComment().isEmpty() ? null : getPresenter().getCommitComment());
requestModel.setCommitId(pullRequest.getHead().getSha());
boolean isAuthor = Login.getUser().getLogin().equalsIgnoreCase(author.getLogin());
ReviewChangesActivity.Companion.startForResult(requestModel, getPresenter().getRepoId(), getPresenter().getLogin(), pullRequest.getNumber(), isAuthor, isEnterprise(), pullRequest.isMerged() || pullRequest.getState() == IssueState.closed).show(getSupportFragmentManager(), ReviewChangesActivity.class.getSimpleName());
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class PullRequestPagerActivity method onSetupIssue.
@Override
public void onSetupIssue(boolean update) {
hideProgress();
if (getPresenter().getPullRequest() == null) {
return;
}
invalidateOptionsMenu();
PullRequest pullRequest = getPresenter().getPullRequest();
setTaskName(pullRequest.getRepoId() + " - " + pullRequest.getTitle());
updateViews(pullRequest);
if (update) {
PullRequestTimelineFragment issueDetailsView = getPullRequestTimelineFragment();
if (issueDetailsView != null && getPresenter().getPullRequest() != null) {
issueDetailsView.onUpdateHeader();
}
} else {
if (pager.getAdapter() == null) {
pager.setAdapter(new FragmentsPagerAdapter(getSupportFragmentManager(), FragmentPagerAdapterModel.buildForPullRequest(this, pullRequest)));
tabs.setupWithViewPager(pager);
tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(pager) {
@Override
public void onTabReselected(TabLayout.Tab tab) {
super.onTabReselected(tab);
onScrollTop(tab.getPosition());
}
});
} else {
onUpdateTimeline();
}
}
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
hideShowFab();
super.onPageSelected(position);
}
});
initTabs(pullRequest);
hideShowFab();
AnimHelper.mimicFabVisibility(getPresenter().hasReviewComments(), prReviewHolder, null);
reviewsCount.setText(String.format("%s", getPresenter().getCommitComment().size()));
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class PullRequestPagerPresenter method onPutAssignees.
@Override
public void onPutAssignees(@NonNull ArrayList<User> users, boolean isAssignees) {
AssigneesRequestModel assigneesRequestModel = new AssigneesRequestModel();
ArrayList<String> assignees = Stream.of(users).map(User::getLogin).collect(Collectors.toCollection(ArrayList::new));
if (isAssignees) {
assigneesRequestModel.setAssignees(assignees.isEmpty() ? Stream.of(pullRequest.getAssignees()).map(User::getLogin).toList() : assignees);
makeRestCall(!assignees.isEmpty() ? RestProvider.getIssueService(isEnterprise()).putAssignees(login, repoId, issueNumber, assigneesRequestModel) : RestProvider.getIssueService(isEnterprise()).deleteAssignees(login, repoId, issueNumber, assigneesRequestModel), pullRequestResponse -> {
UsersListModel usersListModel = new UsersListModel();
usersListModel.addAll(users);
this.pullRequest.setAssignees(usersListModel);
manageObservable(pullRequest.save(pullRequest).toObservable());
sendToView(view -> updateTimeline(view, R.string.assignee_added));
});
} else {
assigneesRequestModel.setReviewers(assignees);
makeRestCall(RestProvider.getPullRequestService(isEnterprise()).putReviewers(login, repoId, issueNumber, assigneesRequestModel), pullRequestResponse -> sendToView(view -> updateTimeline(view, R.string.reviewer_added)));
}
}
use of com.fastaccess.data.dao.model.PullRequest 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));
}
});
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class PullRequestFilesFragment method setupChanges.
private void setupChanges() {
PullRequest pullRequest = issueCallback.getData();
if (pullRequest != null) {
addition.setText(String.valueOf(pullRequest.getAdditions()));
deletion.setText(String.valueOf(pullRequest.getDeletions()));
changes.setText(String.valueOf(pullRequest.getChangedFiles()));
}
}
Aggregations