Search in sources :

Example 1 with CommentItemDecoration

use of com.odysee.app.adapter.CommentItemDecoration in project odysee-android by OdyseeTeam.

the class FileViewFragment method ensureCommentListAdapterCreated.

private void ensureCommentListAdapterCreated(final List<Comment> comments) {
    Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
    if (commentListAdapter == null) {
        final Context androidContext = getContext();
        final View root = getView();
        commentListAdapter = new CommentListAdapter(comments, getContext(), actualClaim, new CommentListAdapter.CommentListListener() {

            @Override
            public void onListChanged() {
                checkNoComments();
            }

            @Override
            public void onCommentReactClicked(Comment c, boolean liked) {
                react(c, liked);
            }

            @Override
            public void onReplyClicked(Comment comment) {
                setReplyToComment(comment);
            }
        });
        commentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {

            @Override
            public void onClaimClicked(Claim claim, int position) {
                if (!Helper.isNullOrEmpty(claim.getName()) && claim.getName().startsWith("@") && androidContext instanceof MainActivity) {
                    removeNotificationAsSource();
                    ((MainActivity) androidContext).openChannelClaim(claim);
                }
            }
        });
        RecyclerView commentsList = root.findViewById(R.id.file_view_comments_list);
        // Indent reply-type items
        int marginInPx = Math.round(40 * ((float) androidContext.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT));
        commentsList.addItemDecoration(new CommentItemDecoration(marginInPx));
        commentsList.setAdapter(commentListAdapter);
        commentListAdapter.notifyItemRangeInserted(0, comments.size());
        scrollToCommentHash();
        checkNoComments();
        resolveCommentPosters();
    }
}
Also used : AttributeProviderContext(org.commonmark.renderer.html.AttributeProviderContext) Context(android.content.Context) Comment(com.odysee.app.model.Comment) ReactToComment(com.odysee.app.runnable.ReactToComment) CommentListAdapter(com.odysee.app.adapter.CommentListAdapter) MainActivity(com.odysee.app.MainActivity) CommentItemDecoration(com.odysee.app.adapter.CommentItemDecoration) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) ClaimListAdapter(com.odysee.app.adapter.ClaimListAdapter) SuppressLint(android.annotation.SuppressLint) RecyclerView(androidx.recyclerview.widget.RecyclerView) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) Claim(com.odysee.app.model.Claim)

Example 2 with CommentItemDecoration

use of com.odysee.app.adapter.CommentItemDecoration in project odysee-android by OdyseeTeam.

the class ChannelCommentsFragment method ensureCommentListAdapterCreated.

private void ensureCommentListAdapterCreated(final List<Comment> comments) {
    if (commentListAdapter == null) {
        Context ctx = getContext();
        View root = getView();
        commentListAdapter = new CommentListAdapter(comments, ctx, claim, new CommentListAdapter.CommentListListener() {

            @Override
            public void onListChanged() {
                checkNoComments();
            }

            @Override
            public void onCommentReactClicked(Comment c, boolean liked) {
            // Not used for now.
            }

            @Override
            public void onReplyClicked(Comment comment) {
                setReplyToComment(comment);
            }
        });
        commentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {

            @Override
            public void onClaimClicked(Claim claim, int position) {
                if (!Helper.isNullOrEmpty(claim.getName()) && claim.getName().startsWith("@") && ctx instanceof MainActivity) {
                    ((MainActivity) ctx).openChannelClaim(claim);
                }
            }
        });
        RecyclerView commentList = root.findViewById(R.id.channel_comments_list);
        int marginInPx = Math.round(40 * ((float) ctx.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT));
        commentList.addItemDecoration(new CommentItemDecoration(marginInPx));
        commentList.setAdapter(commentListAdapter);
        commentListAdapter.notifyItemRangeInserted(0, comments.size());
        commentListAdapter.setCollapsed(false);
        checkNoComments();
        resolveCommentPosters();
        scrollToCommentHash();
    }
}
Also used : Context(android.content.Context) Comment(com.odysee.app.model.Comment) CommentListAdapter(com.odysee.app.adapter.CommentListAdapter) MainActivity(com.odysee.app.MainActivity) CommentItemDecoration(com.odysee.app.adapter.CommentItemDecoration) NestedScrollView(androidx.core.widget.NestedScrollView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) ClaimListAdapter(com.odysee.app.adapter.ClaimListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) Claim(com.odysee.app.model.Claim)

Aggregations

Context (android.content.Context)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 NestedScrollView (androidx.core.widget.NestedScrollView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 MainActivity (com.odysee.app.MainActivity)2 ClaimListAdapter (com.odysee.app.adapter.ClaimListAdapter)2 CommentItemDecoration (com.odysee.app.adapter.CommentItemDecoration)2 CommentListAdapter (com.odysee.app.adapter.CommentListAdapter)2 Claim (com.odysee.app.model.Claim)2 Comment (com.odysee.app.model.Comment)2 SuppressLint (android.annotation.SuppressLint)1 WebView (android.webkit.WebView)1 PhotoView (com.github.chrisbanes.photoview.PhotoView)1 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)1 PlayerView (com.google.android.exoplayer2.ui.PlayerView)1 ReactToComment (com.odysee.app.runnable.ReactToComment)1 SolidIconView (com.odysee.app.ui.controls.SolidIconView)1