12
12
13
13
import bttv .settings .Settings ;
14
14
import tv .twitch .android .app .core .ThemeManager ;
15
+ import tv .twitch .android .shared .chat .adapter .item .ChatMessageViewHolder ;
15
16
import tv .twitch .android .shared .chat .chomments .ChommentRecyclerItem .ChommentItemViewHolder ;
16
17
import tv .twitch .android .shared .chat .messagefactory .adapteritem .UserNoticeRecyclerItem .UserNoticeViewHolder ;
17
18
@@ -49,7 +50,8 @@ public static void setBackgroundColor(int position, RecyclerView.ViewHolder view
49
50
// so make sure not to do anything when
50
51
// not a ViewHolder used in Chat
51
52
if (
52
- !(viewHolder instanceof ChommentItemViewHolder )
53
+ !(viewHolder instanceof ChatMessageViewHolder )
54
+ && !(viewHolder instanceof ChommentItemViewHolder )
53
55
&& !(viewHolder instanceof UserNoticeViewHolder )
54
56
) {
55
57
Log .i (TAG , "viewHolder is not known: " + viewHolder .toString ());
@@ -58,12 +60,30 @@ public static void setBackgroundColor(int position, RecyclerView.ViewHolder view
58
60
View view = viewHolder .itemView ;
59
61
Context context = view .getContext ();
60
62
61
- // make sure we only change chat message items
62
- boolean hasChatMessageId = view .getId () == ResUtil .getResourceId (context , "chat_message_item" , "id" );
63
- boolean hasChommentRootId = view .getId () == ResUtil .getResourceId (context , "chomment_root_view" , "id" );
63
+ // make sure we only change chat message items,
64
+ // which are LinearLayouts with chat_message_item children.
65
+ // Anything else is ignored.
66
+ int chatMessageItemResId = ResUtil .getResourceId (context , "chat_message_item" , "id" );
67
+ int chommentRootViewResId = ResUtil .getResourceId (context , "chomment_root_view" , "id" );
68
+ if (view instanceof LinearLayout ) {
69
+ Log .d (TAG , "view is LinearLayout: " + view .toString ());
70
+ LinearLayout linearLayout = (LinearLayout ) view ;
71
+ for (int j = 0 ; j < linearLayout .getChildCount (); j ++) {
72
+ View nestedChild = linearLayout .getChildAt (j );
73
+ if (nestedChild .getId () == chatMessageItemResId ) {
74
+ Log .d (TAG , "found chat_message_item: " + nestedChild .toString ());
75
+ view = nestedChild ;
76
+ // Increase width of linearLayout to match parent to color the whole item
77
+ linearLayout .setLayoutParams (new LinearLayout .LayoutParams (LinearLayout .LayoutParams .MATCH_PARENT , LinearLayout .LayoutParams .WRAP_CONTENT ));
78
+ break ;
79
+ }
80
+ }
81
+ }
82
+ boolean hasChatMessageId = view .getId () == chatMessageItemResId ;
83
+ boolean hasChommentRootId = view .getId () == chommentRootViewResId ;
64
84
65
- if (!hasChatMessageId && ! hasChommentRootId ) {
66
- Log .i (TAG , "view skipped, as it's not a chat message or chomment" + viewHolder .toString ());
85
+ if (!( hasChatMessageId || hasChommentRootId ) ) {
86
+ Log .d (TAG , "view skipped, as it's not a chat message or chomment, " + viewHolder .toString () + " ID: " + view . getId () + " View: " + view . toString () + " Expected ID: " + chatMessageItemResId + " or " + chommentRootViewResId );
67
87
reset (view );
68
88
return ;
69
89
}
0 commit comments