Search in sources :

Example 1 with ReactionTypes

use of com.fastaccess.data.dao.types.ReactionTypes in project FastHub by k0shk0sh.

the class ReactionsProvider method isPreviouslyReacted.

public boolean isPreviouslyReacted(long idOrNumber, @IdRes int vId) {
    ReactionsModel reactionsModel = getReactionsMap().get(idOrNumber);
    if (reactionsModel == null || InputHelper.isEmpty(reactionsModel.getContent())) {
        return false;
    }
    ReactionTypes type = ReactionTypes.get(vId);
    return type != null && type.getContent().equals(reactionsModel.getContent());
}
Also used : ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes) ReactionsModel(com.fastaccess.data.dao.ReactionsModel)

Example 2 with ReactionTypes

use of com.fastaccess.data.dao.types.ReactionTypes in project FastHub by k0shk0sh.

the class PullRequestTimelinePresenter method onLongClick.

@Override
public void onLongClick(int groupPosition, int commentPosition, @NonNull View v, @NonNull ReviewCommentModel model) {
    if (getView() == null || getView().getPullRequest() == null)
        return;
    PullRequest pullRequest = getView().getPullRequest();
    String login = pullRequest.getLogin();
    String repoId = pullRequest.getRepoId();
    if (!InputHelper.isEmpty(login) && !InputHelper.isEmpty(repoId)) {
        ReactionTypes type = ReactionTypes.get(v.getId());
        if (type != null) {
            getView().showReactionsPopup(type, login, repoId, model.getId(), ReactionsProvider.REVIEW_COMMENT);
        } else {
            onClick(groupPosition, commentPosition, v, model);
        }
    }
}
Also used : PullRequest(com.fastaccess.data.dao.model.PullRequest) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes)

Example 3 with ReactionTypes

use of com.fastaccess.data.dao.types.ReactionTypes in project FastHub by k0shk0sh.

the class PullRequestTimelinePresenter method onItemLongClick.

@Override
public void onItemLongClick(int position, View v, TimelineModel item) {
    if (getView() == null || getView().getPullRequest() == 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 {
            PullRequest pullRequest = getView().getPullRequest();
            String login = pullRequest.getLogin();
            String repoId = pullRequest.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.getPullRequest().getNumber(), ReactionsProvider.HEADER);
                    } else {
                        getView().showReactionsPopup(type, login, repoId, item.getComment().getId(), ReactionsProvider.COMMENT);
                    }
                } else {
                    onItemClick(position, v, item);
                }
            }
        }
    } else {
        onItemClick(position, v, item);
    }
}
Also used : Comment(com.fastaccess.data.dao.model.Comment) PullRequest(com.fastaccess.data.dao.model.PullRequest) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes)

Example 4 with ReactionTypes

use of com.fastaccess.data.dao.types.ReactionTypes 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);
    }
}
Also used : Comment(com.fastaccess.data.dao.model.Comment) Issue(com.fastaccess.data.dao.model.Issue) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes)

Example 5 with ReactionTypes

use of com.fastaccess.data.dao.types.ReactionTypes in project FastHub by k0shk0sh.

the class ReactionService method onHandleIntent.

@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent != null && intent.getExtras() != null) {
        Bundle bundle = intent.getExtras();
        ReactionTypes reactionType = (ReactionTypes) bundle.getSerializable(BundleConstant.EXTRA_TYPE);
        boolean isCommit = bundle.getBoolean(BundleConstant.EXTRA);
        String login = bundle.getString(BundleConstant.EXTRA_TWO);
        String repo = bundle.getString(BundleConstant.EXTRA_THREE);
        long commentId = bundle.getLong(BundleConstant.ID);
        boolean isEnterprise = bundle.getBoolean(BundleConstant.IS_ENTERPRISE);
        if (InputHelper.isEmpty(login) || InputHelper.isEmpty(repo) || reactionType == null) {
            stopSelf();
            return;
        }
        if (isCommit) {
            postCommit(reactionType, login, repo, commentId, isEnterprise);
        } else {
            post(reactionType, login, repo, commentId, isEnterprise);
        }
    }
}
Also used : Bundle(android.os.Bundle) ReactionTypes(com.fastaccess.data.dao.types.ReactionTypes)

Aggregations

ReactionTypes (com.fastaccess.data.dao.types.ReactionTypes)6 ReactionsModel (com.fastaccess.data.dao.ReactionsModel)2 Comment (com.fastaccess.data.dao.model.Comment)2 PullRequest (com.fastaccess.data.dao.model.PullRequest)2 Bundle (android.os.Bundle)1 Issue (com.fastaccess.data.dao.model.Issue)1