99import android .util .Log ;
1010import android .view .View ;
1111import android .view .ViewGroup ;
12+ import android .widget .Button ;
1213import android .widget .ImageView ;
1314import android .widget .RelativeLayout ;
1415import android .widget .TextView ;
@@ -57,15 +58,20 @@ public class CommentInfoItemHolder extends InfoItemHolder {
5758 private final RelativeLayout itemRoot ;
5859 private final ImageView itemThumbnailView ;
5960 private final TextView itemContentView ;
61+ private final ImageView itemThumbsUpView ;
6062 private final TextView itemLikesCountView ;
6163 private final TextView itemTitleView ;
6264 private final ImageView itemHeartView ;
6365 private final ImageView itemPinnedView ;
66+ private final Button repliesButton ;
6467
6568 private final CompositeDisposable disposables = new CompositeDisposable ();
66- @ Nullable private Description commentText ;
67- @ Nullable private StreamingService streamService ;
68- @ Nullable private String streamUrl ;
69+ @ Nullable
70+ private Description commentText ;
71+ @ Nullable
72+ private StreamingService streamService ;
73+ @ Nullable
74+ private String streamUrl ;
6975
7076 public CommentInfoItemHolder (final InfoItemBuilder infoItemBuilder ,
7177 final ViewGroup parent ) {
@@ -74,10 +80,12 @@ public CommentInfoItemHolder(final InfoItemBuilder infoItemBuilder,
7480 itemRoot = itemView .findViewById (R .id .itemRoot );
7581 itemThumbnailView = itemView .findViewById (R .id .itemThumbnailView );
7682 itemContentView = itemView .findViewById (R .id .itemCommentContentView );
83+ itemThumbsUpView = itemView .findViewById (R .id .detail_thumbs_up_img_view );
7784 itemLikesCountView = itemView .findViewById (R .id .detail_thumbs_up_count_view );
7885 itemTitleView = itemView .findViewById (R .id .itemTitleView );
7986 itemHeartView = itemView .findViewById (R .id .detail_heart_image_view );
8087 itemPinnedView = itemView .findViewById (R .id .detail_pinned_view );
88+ repliesButton = itemView .findViewById (R .id .replies_button );
8189
8290 commentHorizontalPadding = (int ) infoItemBuilder .getContext ()
8391 .getResources ().getDimension (R .dimen .comments_horizontal_padding );
@@ -97,6 +105,8 @@ public void updateFromItem(final InfoItem infoItem,
97105 }
98106 final CommentsInfoItem item = (CommentsInfoItem ) infoItem ;
99107
108+
109+ // load the author avatar
100110 PicassoHelper .loadAvatar (item .getUploaderAvatars ()).into (itemThumbnailView );
101111 if (ImageStrategy .shouldLoadImages ()) {
102112 itemThumbnailView .setVisibility (View .VISIBLE );
@@ -109,6 +119,10 @@ public void updateFromItem(final InfoItem infoItem,
109119 }
110120 itemThumbnailView .setOnClickListener (view -> openCommentAuthor (item ));
111121
122+
123+ // setup the top row, with pinned icon, author name and comment date
124+ itemPinnedView .setVisibility (item .isPinned () ? View .VISIBLE : View .GONE );
125+
112126 final String uploadDate ;
113127 if (item .getUploadDate () != null ) {
114128 uploadDate = Localization .relativeTime (item .getUploadDate ().offsetDateTime ());
@@ -117,9 +131,29 @@ public void updateFromItem(final InfoItem infoItem,
117131 }
118132 itemTitleView .setText (Localization .concatenateStrings (item .getUploaderName (), uploadDate ));
119133
120- itemPinnedView .setVisibility (item .isPinned () ? View .VISIBLE : View .GONE );
134+
135+ // setup bottom row, with likes, heart and replies button
136+ if (item .getLikeCount () >= 0 ) {
137+ itemLikesCountView .setText (
138+ Localization .shortCount (
139+ itemBuilder .getContext (),
140+ item .getLikeCount ()));
141+ } else {
142+ itemLikesCountView .setText ("-" );
143+ }
144+
121145 itemHeartView .setVisibility (item .isHeartedByUploader () ? View .VISIBLE : View .GONE );
122146
147+ final boolean hasReplies = item .getReplies () != null ;
148+ repliesButton .setOnClickListener (hasReplies ? (v ) -> openRepliesFragment () : null );
149+ repliesButton .setVisibility (hasReplies ? View .VISIBLE : View .GONE );
150+ repliesButton .setText (hasReplies
151+ ? Localization .replyCount (itemBuilder .getContext (), item .getReplyCount ()) : "" );
152+ ((RelativeLayout .LayoutParams ) itemThumbsUpView .getLayoutParams ()).topMargin =
153+ hasReplies ? 0 : DeviceUtils .dpToPx (6 , itemBuilder .getContext ());
154+
155+
156+ // setup comment content and click listeners to expand/ellipsize it
123157 try {
124158 streamService = NewPipe .getService (item .getServiceId ());
125159 } catch (final ExtractionException e ) {
@@ -135,16 +169,6 @@ public void updateFromItem(final InfoItem infoItem,
135169 //noinspection ClickableViewAccessibility
136170 itemContentView .setOnTouchListener (CommentTextOnTouchListener .INSTANCE );
137171
138- if (item .getLikeCount () >= 0 ) {
139- itemLikesCountView .setText (
140- Localization .shortCount (
141- itemBuilder .getContext (),
142- item .getLikeCount ()));
143- } else {
144- itemLikesCountView .setText ("-" );
145- }
146-
147-
148172 itemView .setOnClickListener (view -> {
149173 toggleEllipsize ();
150174 if (itemBuilder .getOnCommentsSelectedListener () != null ) {
@@ -278,4 +302,8 @@ private void linkifyCommentContentView(@Nullable final Consumer<TextView> onComp
278302 onCompletion );
279303 }
280304 }
305+
306+ private void openRepliesFragment () {
307+ // TODO
308+ }
281309}
0 commit comments