(int position, RecyclerView.ViewHolder viewHolder)
| 42 | private static int totalRemovedMessages = 0; |
| 43 | |
| 44 | public static void setBackgroundColor(int position, RecyclerView.ViewHolder viewHolder) { |
| 45 | if (!ResUtil.getBooleanFromSettings(Settings.SplitChatEnabled)) { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | // TwitchAdapter is used all over the place, |
| 50 | // so make sure not to do anything when |
| 51 | // not a ViewHolder used in Chat |
| 52 | if ( |
| 53 | !(viewHolder instanceof ChatMessageViewHolder) |
| 54 | && !(viewHolder instanceof ChommentItemViewHolder) |
| 55 | && !(viewHolder instanceof UserNoticeViewHolder) |
| 56 | ) { |
| 57 | Log.i(TAG, "viewHolder is not known: " + viewHolder.toString()); |
| 58 | return; |
| 59 | } |
| 60 | View view = viewHolder.itemView; |
| 61 | Context context = view.getContext(); |
| 62 | |
| 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; |
| 84 | |
| 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); |
| 87 | reset(view); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | int color = ThemeManager.Companion.isNightModeEnabled(context) |
| 92 | ? ResUtil.getColorValue("material_grey_900") |
| 93 | : ResUtil.getColorValue("material_grey_300"); |
| 94 | |
| 95 | boolean doChange = shouldTintBG(position); |
| 96 | |
| 97 | // for some reason we can't set the background for the whole view for Chomments (VODs) |
| 98 | // so we just highlight the TextView (first child) |
| 99 | if (hasChommentRootId) { |
| 100 | LinearLayout linearLayout = (LinearLayout) view; |
| 101 | view = linearLayout.getChildAt(0); |
nothing calls this directly
no test coverage detected