Search in sources :

Example 6 with TimelineModel

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

the class PullRequestTimelineFragment method onRemoveReviewComment.

@Override
public void onRemoveReviewComment(int groupPosition, int commentPosition) {
    hideProgress();
    TimelineModel timelineModel = adapter.getItem(groupPosition);
    if (timelineModel != null && timelineModel.getGroupedReviewModel() != null) {
        if (timelineModel.getGroupedReviewModel().getComments() != null) {
            timelineModel.getGroupedReviewModel().getComments().remove(commentPosition);
            if (timelineModel.getGroupedReviewModel().getComments().isEmpty()) {
                adapter.removeItem(groupPosition);
            } else {
                adapter.notifyItemChanged(groupPosition);
            }
        }
    }
}
Also used : TimelineModel(com.fastaccess.data.dao.TimelineModel)

Example 7 with TimelineModel

use of com.fastaccess.data.dao.TimelineModel 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 8 with TimelineModel

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

Aggregations

TimelineModel (com.fastaccess.data.dao.TimelineModel)8 Comment (com.fastaccess.data.dao.model.Comment)4 Bundle (android.os.Bundle)3 Activity (android.app.Activity)2 Uri (android.net.Uri)2 NonNull (android.support.annotation.NonNull)2 Nullable (android.support.annotation.Nullable)2 View (android.view.View)2 PopupMenu (android.widget.PopupMenu)2 R (com.fastaccess.R)2 CommentRequestModel (com.fastaccess.data.dao.CommentRequestModel)2 EditReviewCommentModel (com.fastaccess.data.dao.EditReviewCommentModel)2 ReactionsModel (com.fastaccess.data.dao.ReactionsModel)2 Issue (com.fastaccess.data.dao.model.Issue)2 Login (com.fastaccess.data.dao.model.Login)2 PullRequest (com.fastaccess.data.dao.model.PullRequest)2 GenericEvent (com.fastaccess.data.dao.timeline.GenericEvent)2 SourceModel (com.fastaccess.data.dao.timeline.SourceModel)2 ReactionTypes (com.fastaccess.data.dao.types.ReactionTypes)2 ActivityHelper (com.fastaccess.helper.ActivityHelper)2