Search in sources :

Example 6 with Comment

use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.

the class ControllerComments method reloadAllComments.

public void reloadAllComments() {
    if (TextUtils.isEmpty(link.getId())) {
        setLoading(false);
        return;
    }
    if (link.getContextLevel() > 0 && !TextUtils.isEmpty(link.getCommentId())) {
        loadCommentThread();
        return;
    }
    if (!link.getComments().getChildren().isEmpty()) {
        Comment commentFirst = ((Comment) link.getComments().getChildren().get(0));
        if (!commentFirst.getParentId().equals(link.getId())) {
            link.setCommentId(commentFirst.getId());
            loadCommentThread();
            return;
        }
    }
    loadLinkComments();
}
Also used : Comment(com.winsonchiu.reader.data.reddit.Comment)

Example 7 with Comment

use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.

the class ControllerComments method insertComment.

public void insertComment(Comment comment) {
    // Check to see if comment is actually a part of the link's comment thread
    if (!comment.getLinkId().equals(link.getName())) {
        return;
    }
    Comment parentComment = new Comment();
    parentComment.setId(comment.getParentId());
    int commentIndex;
    if (link.getComments() != null) {
        commentIndex = link.getComments().getChildren().indexOf(parentComment);
        if (commentIndex > -1) {
            parentComment = (Comment) link.getComments().getChildren().get(commentIndex);
            comment.setLevel(parentComment.getLevel() + 1);
        }
        link.getComments().getChildren().add(commentIndex + 1, comment);
    }
    if (listingComments != null) {
        commentIndex = listingComments.getChildren().indexOf(parentComment);
        if (commentIndex > -1) {
            parentComment = (Comment) listingComments.getChildren().get(commentIndex);
            comment.setLevel(parentComment.getLevel() + 1);
        }
        listingComments.getChildren().add(commentIndex + 1, comment);
        eventHolder.call(new RxAdapterEvent<>(getData(), RxAdapterEvent.Type.INSERT, commentIndex + 2));
    }
}
Also used : Comment(com.winsonchiu.reader.data.reddit.Comment)

Example 8 with Comment

use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.

the class ControllerProfile method insertComment.

public void insertComment(Comment comment) {
    // Placeholder to use ArrayList.indexOfLink() properly
    Comment parentComment = new Comment();
    parentComment.setId(comment.getParentId());
    int commentIndex = data.getChildren().indexOf(parentComment);
    if (commentIndex > -1) {
        // Level and context are set as they are not provided by the send API
        parentComment = (Comment) data.getChildren().get(commentIndex);
        comment.setLevel(parentComment.getLevel() + 1);
        comment.setContext(parentComment.getContext());
        data.getChildren().add(commentIndex + 1, comment);
        for (Listener listener : listeners) {
            listener.getAdapter().notifyItemInserted(commentIndex + 7);
        }
    }
}
Also used : Comment(com.winsonchiu.reader.data.reddit.Comment) ControllerListener(com.winsonchiu.reader.utils.ControllerListener)

Example 9 with Comment

use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.

the class ControllerInbox method insertComment.

public void insertComment(Comment comment) {
    // Placeholder to use ArrayList.indexOfLink() properly
    Comment parentComment = new Comment();
    parentComment.setId(comment.getParentId());
    int commentIndex = data.getChildren().indexOf(parentComment);
    if (commentIndex > -1) {
        // Level and context are set as they are not provided by the send API
        parentComment = (Comment) data.getChildren().get(commentIndex);
        comment.setLevel(parentComment.getLevel() + 1);
        comment.setContext(parentComment.getContext());
        data.getChildren().add(commentIndex + 1, comment);
        for (Listener listener : listeners) {
            listener.getAdapter().notifyItemInserted(commentIndex + 1);
        }
    }
}
Also used : Comment(com.winsonchiu.reader.data.reddit.Comment) ControllerListener(com.winsonchiu.reader.utils.ControllerListener)

Example 10 with Comment

use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.

the class FragmentReply method newInstance.

public static FragmentReply newInstance(Replyable replyable) {
    FragmentReply fragment = new FragmentReply();
    Bundle args = new Bundle();
    args.putString(ARG_NAME_PARENT, replyable.getName());
    args.putCharSequence(ARG_TEXT, replyable.getReplyText());
    args.putCharSequence(ARG_TEXT_PARENT, replyable.getParentHtml());
    if (replyable instanceof Comment) {
        args.putBoolean(ARG_IS_EDIT, ((Comment) replyable).isEditMode());
        args.putInt(ARG_COMMENT_LEVEL, ((Comment) replyable).getLevel());
    }
    fragment.setArguments(args);
    return fragment;
}
Also used : Comment(com.winsonchiu.reader.data.reddit.Comment) Bundle(android.os.Bundle)

Aggregations

Comment (com.winsonchiu.reader.data.reddit.Comment)17 Thing (com.winsonchiu.reader.data.reddit.Thing)7 Listing (com.winsonchiu.reader.data.reddit.Listing)4 Bundle (android.os.Bundle)3 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 AdapterListener (com.winsonchiu.reader.adapter.AdapterListener)3 Likes (com.winsonchiu.reader.data.reddit.Likes)3 Link (com.winsonchiu.reader.data.reddit.Link)3 Intent (android.content.Intent)2 AppBarLayout (android.support.design.widget.AppBarLayout)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)2 AppCompatSpinner (android.support.v7.widget.AppCompatSpinner)2 ContextThemeWrapper (android.view.ContextThemeWrapper)2 AdapterView (android.widget.AdapterView)2 ControllerListener (com.winsonchiu.reader.utils.ControllerListener)2 LinkedList (java.util.LinkedList)2 Account (android.accounts.Account)1