Skip to content

Commit e131ec7

Browse files
committed
dedicated compact live chat UI
1 parent b3b1f9d commit e131ec7

File tree

4 files changed

+375
-15
lines changed

4 files changed

+375
-15
lines changed

libraries/sdk/src/main/java/com/fastcomments/sdk/CommentViewHolder.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.widget.Button;
1212
import android.widget.ImageButton;
1313
import android.widget.ImageView;
14+
import android.widget.LinearLayout;
1415
import android.widget.PopupMenu;
1516
import android.widget.ProgressBar;
1617
import android.widget.TextView;
@@ -103,24 +104,14 @@ public CommentViewHolder(Context context, FastCommentsSDK sdk, @NonNull View ite
103104
private boolean liveChatStyle = false;
104105

105106
/**
106-
* Set whether to use live chat styling (smaller avatars, hidden dates)
107+
* Set whether this view is using live chat styling
107108
* @param liveChatStyle True for live chat style
108109
*/
109110
public void setLiveChatStyle(boolean liveChatStyle) {
110111
this.liveChatStyle = liveChatStyle;
111112

112-
// Update avatar size
113-
ViewGroup.LayoutParams avatarParams = avatarImageView.getLayoutParams();
114-
if (liveChatStyle) {
115-
// Smaller avatar for live chat
116-
avatarParams.width = (int) (context.getResources().getDisplayMetrics().density * 28);
117-
avatarParams.height = (int) (context.getResources().getDisplayMetrics().density * 28);
118-
} else {
119-
// Regular avatar size
120-
avatarParams.width = (int) (context.getResources().getDisplayMetrics().density * 40);
121-
avatarParams.height = (int) (context.getResources().getDisplayMetrics().density * 40);
122-
}
123-
avatarImageView.setLayoutParams(avatarParams);
113+
// No need to modify the view since we're using different layouts
114+
// Just store the flag for other behavior adjustments
124115
}
125116

126117
public void setComment(final RenderableComment comment, boolean disableUnverifiedLabel, final CommentsAdapter.OnToggleRepliesListener listener) {
@@ -189,6 +180,8 @@ public void setComment(final RenderableComment comment, boolean disableUnverifie
189180
// Display the comment content with clickable links
190181
String htmlContent = comment.getComment().getCommentHTML();
191182
contentTextView.setText(HtmlLinkHandler.parseHtml(context, htmlContent, contentTextView));
183+
184+
// No need for special handling for live chat - we're using a dedicated layout
192185

193186
// Indent child comments to reflect hierarchy
194187
ViewGroup.MarginLayoutParams itemViewLayoutParams = (ViewGroup.MarginLayoutParams) itemView.getLayoutParams();

libraries/sdk/src/main/java/com/fastcomments/sdk/CommentsAdapter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ public int getItemViewType(int position) {
9292
@Override
9393
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
9494
if (viewType == VIEW_TYPE_COMMENT) {
95-
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false);
95+
// Use compact layout for live chat mode
96+
int layoutResId = commentsTree.liveChatStyle ?
97+
R.layout.item_comment_compact : R.layout.item_comment;
98+
99+
View view = LayoutInflater.from(parent.getContext()).inflate(layoutResId, parent, false);
96100
return new CommentViewHolder(context, sdk, view);
97101
} else if (viewType == VIEW_TYPE_DATE_SEPARATOR) {
98102
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.date_separator, parent, false);
@@ -122,7 +126,7 @@ private void bindDateSeparatorViewHolder(DateSeparatorViewHolder holder, int pos
122126
private void bindCommentViewHolder(CommentViewHolder holder, int position) {
123127
final RenderableComment comment = (RenderableComment) commentsTree.visibleNodes.get(position);
124128

125-
// Set live chat style for smaller avatars and hidden dates
129+
// Inform the holder whether we're in live chat mode
126130
holder.setLiveChatStyle(commentsTree.liveChatStyle);
127131

128132
// Pass config setting for unverified label

libraries/sdk/src/main/res/layout/item_comment.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
android:contentDescription="@string/pinned_comment" />
2525

2626
<LinearLayout
27+
android:id="@+id/commentContainer"
2728
android:layout_width="match_parent"
2829
android:layout_height="wrap_content"
2930
android:orientation="vertical"
3031
android:padding="8dp">
3132

3233
<LinearLayout
34+
android:id="@+id/commentHeader"
3335
android:layout_width="match_parent"
3436
android:layout_height="wrap_content"
3537
android:orientation="horizontal">
@@ -60,6 +62,7 @@
6062
</FrameLayout>
6163

6264
<LinearLayout
65+
android:id="@+id/commentInfoContainer"
6366
android:layout_width="0dp"
6467
android:layout_height="wrap_content"
6568
android:layout_marginStart="8dp"

0 commit comments

Comments
 (0)