use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class PullRequestTimelinePresenter method onHandleDeletion.
@Override
public void onHandleDeletion(@Nullable Bundle bundle) {
if (getView() == null || getView().getPullRequest() == null)
return;
if (bundle != null) {
PullRequest pullRequest = getView().getPullRequest();
String login = pullRequest.getLogin();
String repoId = pullRequest.getRepoId();
long commId = bundle.getLong(BundleConstant.EXTRA, 0);
boolean isReviewComment = bundle.getBoolean(BundleConstant.YES_NO_EXTRA);
if (commId != 0 && !isReviewComment) {
makeRestCall(RestProvider.getIssueService(isEnterprise()).deleteIssueComment(login, repoId, commId), booleanResponse -> sendToView(view -> {
if (booleanResponse.code() == 204) {
Comment comment = new Comment();
comment.setId(commId);
view.onRemove(TimelineModel.constructComment(comment));
} else {
view.showMessage(R.string.error, R.string.error_deleting_comment);
}
}));
} else {
int groupPosition = bundle.getInt(BundleConstant.EXTRA_TWO);
int commentPosition = bundle.getInt(BundleConstant.EXTRA_THREE);
makeRestCall(RestProvider.getReviewService(isEnterprise()).deleteComment(login, repoId, commId), booleanResponse -> sendToView(view -> {
if (booleanResponse.code() == 204) {
view.onRemoveReviewComment(groupPosition, commentPosition);
} else {
view.showMessage(R.string.error, R.string.error_deleting_comment);
}
}));
}
}
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class CreateIssueActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
Bundle bundle = getIntent().getExtras();
login = bundle.getString(BundleConstant.EXTRA);
repoId = bundle.getString(BundleConstant.ID);
isFeedback = bundle.getBoolean(BundleConstant.EXTRA_TWO);
if (bundle.getParcelable(BundleConstant.ITEM) != null) {
if (bundle.getParcelable(BundleConstant.ITEM) instanceof Issue) {
issue = bundle.getParcelable(BundleConstant.ITEM);
setTitle(getString(R.string.update_issue));
} else if (bundle.getParcelable(BundleConstant.ITEM) instanceof PullRequest) {
pullRequest = bundle.getParcelable(BundleConstant.ITEM);
setTitle(getString(R.string.update_pull_request));
}
}
if (issue != null) {
Logger.e(issue.getLabels(), issue.getMilestone(), issue.getAssignees());
if (issue.getLabels() != null) {
onSelectedLabels(new ArrayList<>(issue.getLabels()));
}
if (issue.getAssignees() != null) {
onSelectedAssignees(new ArrayList<>(issue.getAssignees()), false);
}
if (issue.getMilestone() != null) {
milestoneModel = issue.getMilestone();
onMilestoneSelected(milestoneModel);
}
if (!InputHelper.isEmpty(issue.getTitle())) {
if (title.getEditText() != null)
title.getEditText().setText(issue.getTitle());
}
if (!InputHelper.isEmpty(issue.getBody())) {
onSetCode(issue.getBody());
}
}
if (pullRequest != null) {
if (pullRequest.getLabels() != null) {
onSelectedLabels(new ArrayList<>(pullRequest.getLabels()));
}
if (pullRequest.getAssignees() != null) {
users.addAll(pullRequest.getAssignees());
onSelectedAssignees(new ArrayList<>(pullRequest.getAssignees()), false);
}
if (pullRequest.getMilestone() != null) {
milestoneModel = pullRequest.getMilestone();
onMilestoneSelected(milestoneModel);
}
if (!InputHelper.isEmpty(pullRequest.getTitle())) {
if (title.getEditText() != null)
title.getEditText().setText(pullRequest.getTitle());
}
if (!InputHelper.isEmpty(pullRequest.getBody())) {
onSetCode(pullRequest.getBody());
}
}
}
getPresenter().checkAuthority(login, repoId);
if (isFeedback || ("k0shk0sh".equalsIgnoreCase(login) && repoId.equalsIgnoreCase("FastHub"))) {
Toasty.info(App.getInstance(), getString(R.string.report_issue_warning), Toast.LENGTH_LONG).show();
setTitle(R.string.submit_feedback);
getPresenter().onCheckAppVersion();
}
if (BuildConfig.DEBUG && isFeedback) {
alertDialog = new AlertDialog.Builder(this).setTitle("You are currently using a debug build").setMessage("If you have found a bug, please report it on slack." + "\n" + "Feature requests can be submitted here." + "\n" + "Happy Testing").setPositiveButton(android.R.string.ok, null).show();
}
if (toolbar != null)
toolbar.setSubtitle(login + "/" + repoId);
setTaskName(login + "/" + repoId + " - " + (isFeedback ? getString(R.string.submit_feedback) : getString(R.string.create_issue)));
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class FeedsViewHolder method appendPullRequestReviewCommentEvent.
private void appendPullRequestReviewCommentEvent(SpannableBuilder spannableBuilder, Event eventsModel) {
PullRequest pullRequest = eventsModel.getPayload().getPullRequest();
Comment comment = eventsModel.getPayload().getComment();
spannableBuilder.bold("reviewed").append(" ").bold("pull request").append(" ").bold("in").append(" ").append(eventsModel.getRepo().getName()).bold("#").bold(String.valueOf(pullRequest.getNumber()));
if (comment.getBody() != null) {
MarkDownProvider.stripMdText(description, comment.getBody().replaceAll("\\r?\\n|\\r", " "));
description.setVisibility(View.VISIBLE);
} else {
description.setText("");
description.setVisibility(View.GONE);
}
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class FeedsViewHolder method appendPullRequestEvent.
private void appendPullRequestEvent(SpannableBuilder spannableBuilder, Event eventsModel) {
PullRequest issue = eventsModel.getPayload().getPullRequest();
String action = eventsModel.getPayload().getAction();
if ("synchronize".equals(action)) {
action = "updated";
}
if (eventsModel.getPayload().getPullRequest().isMerged()) {
action = "merged";
}
spannableBuilder.bold(action).append(" ").bold("pull request").append(" ").append(eventsModel.getRepo().getName()).bold("#").bold(String.valueOf(issue.getNumber()));
if ("opened".equals(action) || "closed".equals(action)) {
if (issue.getTitle() != null) {
MarkDownProvider.stripMdText(description, issue.getTitle().replaceAll("\\r?\\n|\\r", " "));
description.setVisibility(View.VISIBLE);
} else {
description.setText("");
description.setVisibility(View.GONE);
}
}
}
use of com.fastaccess.data.dao.model.PullRequest in project FastHub by k0shk0sh.
the class IssueDetailsViewHolder method addReactionCount.
private void addReactionCount(View v) {
if (adapter != null) {
TimelineModel timelineModel = (TimelineModel) adapter.getItem(getAdapterPosition());
if (timelineModel == null)
return;
ReactionsModel reactionsModel = null;
PullRequest pullRequest = timelineModel.getPullRequest();
Issue issue = timelineModel.getIssue();
int number = 0;
if (pullRequest != null) {
reactionsModel = pullRequest.getReactions();
number = pullRequest.getNumber();
} else if (issue != null) {
reactionsModel = issue.getReactions();
number = issue.getNumber();
}
if (reactionsModel == null)
reactionsModel = new ReactionsModel();
boolean isReacted = reactionsCallback == null || reactionsCallback.isPreviouslyReacted(number, v.getId());
boolean isCallingApi = reactionsCallback != null && reactionsCallback.isCallingApi(number, v.getId());
switch(v.getId()) {
case R.id.heart:
case R.id.heartReaction:
reactionsModel.setHeart(!isReacted ? reactionsModel.getHeart() + 1 : reactionsModel.getHeart() - 1);
break;
case R.id.sad:
case R.id.sadReaction:
reactionsModel.setConfused(!isReacted ? reactionsModel.getConfused() + 1 : reactionsModel.getConfused() - 1);
break;
case R.id.thumbsDown:
case R.id.thumbsDownReaction:
reactionsModel.setMinusOne(!isReacted ? reactionsModel.getMinusOne() + 1 : reactionsModel.getMinusOne() - 1);
break;
case R.id.thumbsUp:
case R.id.thumbsUpReaction:
reactionsModel.setPlusOne(!isReacted ? reactionsModel.getPlusOne() + 1 : reactionsModel.getPlusOne() - 1);
break;
case R.id.laugh:
case R.id.laughReaction:
reactionsModel.setLaugh(!isReacted ? reactionsModel.getLaugh() + 1 : reactionsModel.getLaugh() - 1);
break;
case R.id.hurray:
case R.id.hurrayReaction:
reactionsModel.setHooray(!isReacted ? reactionsModel.getHooray() + 1 : reactionsModel.getHooray() - 1);
break;
}
if (pullRequest != null) {
pullRequest.setReactions(reactionsModel);
appendEmojies(reactionsModel);
timelineModel.setPullRequest(pullRequest);
} else if (issue != null) {
issue.setReactions(reactionsModel);
appendEmojies(reactionsModel);
timelineModel.setIssue(issue);
}
}
}
Aggregations