use of com.fastaccess.data.dao.MilestoneModel in project FastHub by k0shk0sh.
the class IssuePopupFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
toolbar.setNavigationIcon(R.drawable.ic_clear);
toolbar.setNavigationOnClickListener(view1 -> dismiss());
Bundle bundle = getArguments();
String titleString = bundle.getString(BundleConstant.EXTRA);
String bodyString = bundle.getString(BundleConstant.EXTRA_TWO);
User user = bundle.getParcelable(BundleConstant.EXTRA_THREE);
User assigneeModel = bundle.getParcelable(BundleConstant.EXTRA_FOUR);
ArrayList<LabelModel> labelsList = bundle.getParcelableArrayList(BundleConstant.EXTRA_FIVE);
MilestoneModel milestoneModel = bundle.getParcelable(BundleConstant.EXTRA_SIX);
boolean canComment = bundle.getBoolean(BundleConstant.YES_NO_EXTRA);
commentSection.setVisibility(canComment ? View.VISIBLE : View.GONE);
toolbar.setTitle(String.format("#%s", bundle.getInt(BundleConstant.ID)));
title.setText(titleString);
MarkDownProvider.setMdText(body, bodyString);
if (user != null) {
name.setText(user.getLogin());
avatarLayout.setUrl(user.getAvatarUrl(), user.getLogin(), false, LinkParserHelper.isEnterprise(user.getUrl()));
}
if (assigneeModel == null) {
assigneeLayout.setVisibility(View.GONE);
} else {
assignee.setText(assigneeModel.getLogin());
}
if (labelsList == null || labelsList.isEmpty()) {
labelsLayout.setVisibility(View.GONE);
} else {
SpannableBuilder builder = SpannableBuilder.builder();
for (LabelModel label : labelsList) {
int color = Color.parseColor("#" + label.getColor());
builder.append(" ").append(" " + label.getName() + " ", new LabelSpan(color));
}
labels.setText(builder);
}
if (milestoneModel == null) {
milestoneLayout.setVisibility(View.GONE);
} else {
milestoneTitle.setText(milestoneModel.getTitle());
milestoneDescription.setText(milestoneModel.getDescription());
if (milestoneModel.getDescription() == null) {
milestoneDescription.setVisibility(View.GONE);
}
}
}
use of com.fastaccess.data.dao.MilestoneModel in project FastHub by k0shk0sh.
the class CreateIssuePresenter method onSubmit.
@Override
public void onSubmit(@NonNull String title, @NonNull CharSequence description, @NonNull String login, @NonNull String repo, @Nullable Issue issue, @Nullable PullRequest pullRequestModel, @Nullable ArrayList<LabelModel> labels, @Nullable MilestoneModel milestoneModel, @Nullable ArrayList<User> users) {
boolean isEmptyTitle = InputHelper.isEmpty(title);
if (getView() != null) {
getView().onTitleError(isEmptyTitle);
}
if (!isEmptyTitle) {
if (issue == null && pullRequestModel == null) {
CreateIssueModel createIssue = new CreateIssueModel();
createIssue.setBody(InputHelper.toString(description));
createIssue.setTitle(title);
if (isCollaborator) {
if (labels != null && !labels.isEmpty()) {
createIssue.setLabels(Stream.of(labels).map(LabelModel::getName).collect(Collectors.toCollection(ArrayList::new)));
}
if (users != null && !users.isEmpty()) {
createIssue.setAssignees(Stream.of(users).map(User::getLogin).collect(Collectors.toCollection(ArrayList::new)));
}
if (milestoneModel != null) {
createIssue.setMilestone((long) milestoneModel.getNumber());
}
}
makeRestCall(RestProvider.getIssueService(isEnterprise()).createIssue(login, repo, createIssue), issueModel -> {
if (issueModel != null) {
sendToView(view -> view.onSuccessSubmission(issueModel));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
} else {
if (issue != null) {
issue.setBody(InputHelper.toString(description));
issue.setTitle(title);
int number = issue.getNumber();
if (isCollaborator) {
if (labels != null) {
LabelListModel labelModels = new LabelListModel();
labelModels.addAll(labels);
issue.setLabels(labelModels);
}
if (milestoneModel != null) {
issue.setMilestone(milestoneModel);
}
if (users != null) {
UsersListModel usersListModel = new UsersListModel();
usersListModel.addAll(users);
issue.setAssignees(usersListModel);
}
}
IssueRequestModel requestModel = IssueRequestModel.clone(issue, false);
makeRestCall(RestProvider.getIssueService(isEnterprise()).editIssue(login, repo, number, requestModel), issueModel -> {
if (issueModel != null) {
sendToView(view -> view.onSuccessSubmission(issueModel));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
}
if (pullRequestModel != null) {
int number = pullRequestModel.getNumber();
pullRequestModel.setBody(InputHelper.toString(description));
pullRequestModel.setTitle(title);
if (isCollaborator) {
if (labels != null) {
LabelListModel labelModels = new LabelListModel();
labelModels.addAll(labels);
pullRequestModel.setLabels(labelModels);
}
if (milestoneModel != null) {
pullRequestModel.setMilestone(milestoneModel);
}
if (users != null) {
UsersListModel usersListModel = new UsersListModel();
usersListModel.addAll(users);
pullRequestModel.setAssignees(usersListModel);
}
}
IssueRequestModel requestModel = IssueRequestModel.clone(pullRequestModel, false);
makeRestCall(RestProvider.getPullRequestService(isEnterprise()).editPullRequest(login, repo, number, requestModel).flatMap(pullRequest1 -> RestProvider.getIssueService(isEnterprise()).getIssue(login, repo, number), (pullRequest1, issueReaction) -> {
// hack to get reactions from issue api
if (issueReaction != null) {
pullRequest1.setReactions(issueReaction.getReactions());
}
return pullRequest1;
}), pr -> {
if (pr != null) {
sendToView(view -> view.onSuccessSubmission(pr));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
}
}
}
}
use of com.fastaccess.data.dao.MilestoneModel in project FastHub by k0shk0sh.
the class FilterIssuesActivity method getMilestonesAdapter.
private MilestonesAdapter getMilestonesAdapter() {
if (milestonesAdapter == null) {
if (!getPresenter().getMilestones().isEmpty()) {
MilestoneModel milestone = new MilestoneModel();
milestone.setTitle(getString(R.string.clear));
getPresenter().getMilestones().add(0, milestone);
}
milestonesAdapter = new MilestonesAdapter(getPresenter().getMilestones());
milestonesAdapter.setListener(new BaseViewHolder.OnItemClickListener<MilestoneModel>() {
@Override
public void onItemClick(int position, View v, MilestoneModel item) {
appendMilestone(item);
}
@Override
public void onItemLongClick(int position, View v, MilestoneModel item) {
}
});
}
return milestonesAdapter;
}
Aggregations