use of com.fastaccess.data.dao.model.Issue in project FastHub by k0shk0sh.
the class IssueTimelinePresenter method onHandleDeletion.
@Override
public void onHandleDeletion(@Nullable Bundle bundle) {
if (bundle != null) {
long commId = bundle.getLong(BundleConstant.EXTRA, 0);
if (commId != 0) {
if (getView() == null || getView().getIssue() == null)
return;
Issue issue = getView().getIssue();
makeRestCall(RestProvider.getIssueService(isEnterprise()).deleteIssueComment(issue.getLogin(), issue.getRepoId(), 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);
}
}));
}
}
}
use of com.fastaccess.data.dao.model.Issue in project FastHub by k0shk0sh.
the class IssueTimelinePresenter method onHandleComment.
@Override
public void onHandleComment(@NonNull String text, @Nullable Bundle bundle) {
if (getView() == null)
return;
Issue issue = getView().getIssue();
if (issue != null) {
if (bundle == null) {
CommentRequestModel commentRequestModel = new CommentRequestModel();
commentRequestModel.setBody(text);
manageDisposable(RxHelper.getObservable(RestProvider.getIssueService(isEnterprise()).createIssueComment(issue.getLogin(), issue.getRepoId(), issue.getNumber(), commentRequestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showBlockingProgress(0))).subscribe(comment -> sendToView(view -> view.addNewComment(TimelineModel.constructComment(comment))), throwable -> {
onError(throwable);
sendToView(IssueTimelineMvp.View::onHideBlockingProgress);
}));
}
}
}
use of com.fastaccess.data.dao.model.Issue in project FastHub by k0shk0sh.
the class IssueTimelinePresenter method onItemClick.
@Override
public void onItemClick(int position, View v, TimelineModel item) {
if (getView() != null) {
Issue issue = getView().getIssue();
if (issue == null)
return;
if (item.getType() == TimelineModel.COMMENT) {
if (v.getId() == R.id.commentMenu) {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
popupMenu.inflate(R.menu.comments_menu);
String username = Login.getUser().getLogin();
boolean isOwner = CommentsHelper.isOwner(username, issue.getLogin(), item.getComment().getUser().getLogin()) || isCollaborator;
popupMenu.getMenu().findItem(R.id.delete).setVisible(isOwner);
popupMenu.getMenu().findItem(R.id.edit).setVisible(isOwner);
popupMenu.setOnMenuItemClickListener(item1 -> {
if (getView() == null)
return false;
if (item1.getItemId() == R.id.delete) {
getView().onShowDeleteMsg(item.getComment().getId());
} else if (item1.getItemId() == R.id.reply) {
getView().onReply(item.getComment().getUser(), item.getComment().getBody());
} else if (item1.getItemId() == R.id.edit) {
getView().onEditComment(item.getComment());
} else if (item1.getItemId() == R.id.share) {
ActivityHelper.shareUrl(v.getContext(), item.getComment().getHtmlUrl());
}
return true;
});
popupMenu.show();
} else {
onHandleReaction(v.getId(), item.getComment().getId(), ReactionsProvider.COMMENT);
}
} else if (item.getType() == TimelineModel.EVENT) {
GenericEvent issueEventModel = item.getGenericEvent();
if (issueEventModel.getCommitUrl() != null) {
SchemeParser.launchUri(v.getContext(), Uri.parse(issueEventModel.getCommitUrl()));
} else if (issueEventModel.getLabel() != null) {
FilterIssuesActivity.startActivity(v, issue.getLogin(), issue.getRepoId(), true, true, isEnterprise(), "label:\"" + issueEventModel.getLabel().getName() + "\"");
} else if (issueEventModel.getMilestone() != null) {
FilterIssuesActivity.startActivity(v, issue.getLogin(), issue.getRepoId(), true, true, isEnterprise(), "milestone:\"" + issueEventModel.getMilestone().getTitle() + "\"");
} else if (issueEventModel.getAssignee() != null) {
FilterIssuesActivity.startActivity(v, issue.getLogin(), issue.getRepoId(), true, true, isEnterprise(), "assignee:\"" + issueEventModel.getAssignee().getLogin() + "\"");
} else {
SourceModel sourceModel = issueEventModel.getSource();
if (sourceModel != null) {
if (sourceModel.getCommit() != null) {
SchemeParser.launchUri(v.getContext(), sourceModel.getCommit().getUrl());
} else if (sourceModel.getPullRequest() != null) {
SchemeParser.launchUri(v.getContext(), sourceModel.getPullRequest().getUrl());
} else if (sourceModel.getIssue() != null) {
SchemeParser.launchUri(v.getContext(), sourceModel.getIssue().getHtmlUrl());
} else if (sourceModel.getRepository() != null) {
SchemeParser.launchUri(v.getContext(), sourceModel.getRepository().getUrl());
}
}
}
} else if (item.getType() == TimelineModel.HEADER) {
if (v.getId() == R.id.commentMenu) {
PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
popupMenu.inflate(R.menu.comments_menu);
String username = Login.getUser().getLogin();
boolean isOwner = CommentsHelper.isOwner(username, item.getIssue().getLogin(), item.getIssue().getUser().getLogin()) || isCollaborator;
popupMenu.getMenu().findItem(R.id.edit).setVisible(isOwner);
popupMenu.setOnMenuItemClickListener(item1 -> {
if (getView() == null)
return false;
if (item1.getItemId() == R.id.reply) {
getView().onReply(item.getIssue().getUser(), item.getIssue().getBody());
} else if (item1.getItemId() == R.id.edit) {
Activity activity = ActivityHelper.getActivity(v.getContext());
if (activity == null)
return false;
CreateIssueActivity.startForResult(activity, item.getIssue().getLogin(), item.getIssue().getRepoId(), item.getIssue(), isEnterprise());
} else if (item1.getItemId() == R.id.share) {
ActivityHelper.shareUrl(v.getContext(), item.getIssue().getHtmlUrl());
}
return true;
});
popupMenu.show();
} else {
onHandleReaction(v.getId(), item.getIssue().getNumber(), ReactionsProvider.HEADER);
}
}
}
}
use of com.fastaccess.data.dao.model.Issue in project FastHub by k0shk0sh.
the class IssueTimelinePresenter method onItemLongClick.
@Override
public void onItemLongClick(int position, View v, TimelineModel item) {
if (getView() == null)
return;
if (item.getType() == TimelineModel.COMMENT || item.getType() == TimelineModel.HEADER) {
if (v.getId() == R.id.commentMenu && item.getType() == TimelineModel.COMMENT) {
Comment comment = item.getComment();
if (getView() != null)
getView().onReply(comment.getUser(), comment.getBody());
} else {
if (getView().getIssue() == null)
return;
Issue issue = getView().getIssue();
String login = issue.getLogin();
String repoId = issue.getRepoId();
if (!InputHelper.isEmpty(login) && !InputHelper.isEmpty(repoId)) {
ReactionTypes type = ReactionTypes.get(v.getId());
if (type != null) {
if (item.getType() == TimelineModel.HEADER) {
getView().showReactionsPopup(type, login, repoId, item.getIssue().getNumber(), true);
} else {
getView().showReactionsPopup(type, login, repoId, item.getComment().getId(), false);
}
} else {
onItemClick(position, v, item);
}
}
}
} else {
onItemClick(position, v, item);
}
}
use of com.fastaccess.data.dao.model.Issue 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)));
}
Aggregations