Search in sources :

Example 16 with Comment

use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.

the class TimelineCommentsViewHolder method addReactionCount.

private void addReactionCount(View v) {
    if (adapter != null) {
        TimelineModel timelineModel = (TimelineModel) adapter.getItem(getAdapterPosition());
        if (timelineModel == null)
            return;
        Comment comment = timelineModel.getComment();
        if (comment != null) {
            boolean isReacted = reactionsCallback == null || reactionsCallback.isPreviouslyReacted(comment.getId(), v.getId());
            boolean isCallingApi = reactionsCallback != null && reactionsCallback.isCallingApi(comment.getId(), v.getId());
            // if (isCallingApi) return;
            ReactionsModel reactionsModel = comment.getReactions() != null ? comment.getReactions() : new ReactionsModel();
            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;
            }
            comment.setReactions(reactionsModel);
            appendEmojies(reactionsModel);
            timelineModel.setComment(comment);
        }
    }
}
Also used : Comment(com.fastaccess.data.dao.model.Comment) ReactionsModel(com.fastaccess.data.dao.ReactionsModel) TimelineModel(com.fastaccess.data.dao.TimelineModel)

Example 17 with Comment

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

Example 18 with Comment

use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.

the class FeedsViewHolder method appendCommitComment.

private void appendCommitComment(SpannableBuilder spannableBuilder, Event eventsModel) {
    Comment comment = eventsModel.getPayload().getCommitComment() == null ? eventsModel.getPayload().getComment() : eventsModel.getPayload().getCommitComment();
    String commitId = comment != null && comment.getCommitId() != null && comment.getCommitId().length() > 10 ? comment.getCommitId().substring(0, 10) : null;
    spannableBuilder.bold("commented").append(" ").bold("on").append(" ").bold("commit").append(" ").append(eventsModel.getRepo().getName()).url(commitId != null ? "@" + commitId : "");
    if (comment != null && comment.getBody() != null) {
        MarkDownProvider.stripMdText(description, comment.getBody().replaceAll("\\r?\\n|\\r", " "));
        description.setVisibility(View.VISIBLE);
    } else {
        description.setText("");
        description.setVisibility(View.GONE);
    }
}
Also used : Comment(com.fastaccess.data.dao.model.Comment)

Example 19 with Comment

use of com.fastaccess.data.dao.model.Comment in project FastHub by k0shk0sh.

the class FeedsViewHolder method appendIssueCommentEvent.

private void appendIssueCommentEvent(SpannableBuilder spannableBuilder, Event eventsModel) {
    Comment comment = eventsModel.getPayload().getComment();
    Issue issue = eventsModel.getPayload().getIssue();
    spannableBuilder.bold("commented").append(" ").bold("on").append(" ").bold(issue.getPullRequest() != null ? "pull request" : "issue").append(" ").append(eventsModel.getRepo().getName()).bold("#").bold(String.valueOf(issue.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);
    }
}
Also used : Comment(com.fastaccess.data.dao.model.Comment) Issue(com.fastaccess.data.dao.model.Issue)

Aggregations

Comment (com.fastaccess.data.dao.model.Comment)19 Bundle (android.os.Bundle)11 PopupMenu (android.widget.PopupMenu)8 NonNull (android.support.annotation.NonNull)7 Nullable (android.support.annotation.Nullable)7 View (android.view.View)7 R (com.fastaccess.R)7 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)7 TimelineModel (com.fastaccess.data.dao.TimelineModel)7 Login (com.fastaccess.data.dao.model.Login)7 ReactionTypes (com.fastaccess.data.dao.types.ReactionTypes)7 BundleConstant (com.fastaccess.helper.BundleConstant)7 RxHelper (com.fastaccess.helper.RxHelper)7 RestProvider (com.fastaccess.provider.rest.RestProvider)7 BasePresenter (com.fastaccess.ui.base.mvp.presenter.BasePresenter)7 ArrayList (java.util.ArrayList)7 BaseMvp (com.fastaccess.ui.base.mvp.BaseMvp)6 ActivityHelper (com.fastaccess.helper.ActivityHelper)5 CommentsHelper (com.fastaccess.provider.timeline.CommentsHelper)5 ReactionsProvider (com.fastaccess.provider.timeline.ReactionsProvider)5