@@ -74,30 +74,51 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
74
74
}
75
75
if (showOnlineIcon ) {
76
76
var contactView = (FrameLayout ) view .findViewById (Utils .getID ("contact_selector" , "id" ));
77
- var photoView = (ImageView ) contactView .getChildAt (0 );
78
- contactView .removeView (photoView );
79
-
80
- var relativeLayout = new RelativeLayout (context );
81
- relativeLayout .setId (0x7FFF0003 );
82
- var params = new RelativeLayout .LayoutParams (LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .WRAP_CONTENT );
83
- params .addRule (RelativeLayout .CENTER_IN_PARENT );
84
- photoView .setLayoutParams (params );
85
- relativeLayout .addView (photoView );
86
- contactView .addView (relativeLayout );
77
+ var firstChild = contactView .getChildAt (0 );
87
78
var isLeftToRight = TextUtilsCompat .getLayoutDirectionFromLocale (Locale .getDefault ()) == View .LAYOUT_DIRECTION_LTR ;
88
-
89
- var imageView = new ImageView (context );
90
- imageView .setId (0x7FFF0001 );
91
- var params2 = new RelativeLayout .LayoutParams (Utils .dipToPixels (14 ), Utils .dipToPixels (14 ));
92
- params2 .addRule (RelativeLayout .ALIGN_TOP , contactView .getId ());
93
- params2 .addRule (isLeftToRight ? RelativeLayout .ALIGN_RIGHT : RelativeLayout .ALIGN_LEFT , photoView .getId ());
94
- params2 .topMargin = Utils .dipToPixels (5 );
95
- imageView .setLayoutParams (params2 );
96
- imageView .setImageResource (ResId .drawable .online );
97
- imageView .setAdjustViewBounds (true );
98
- imageView .setScaleType (ImageView .ScaleType .FIT_XY );
99
- imageView .setVisibility (View .INVISIBLE );
100
- relativeLayout .addView (imageView );
79
+ if (firstChild instanceof ImageView photoView ) {
80
+ contactView .removeView (photoView );
81
+
82
+ var relativeLayout = new RelativeLayout (context );
83
+ relativeLayout .setId (0x7FFF0003 );
84
+ var params = new RelativeLayout .LayoutParams (LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .WRAP_CONTENT );
85
+ params .addRule (RelativeLayout .CENTER_IN_PARENT );
86
+ photoView .setLayoutParams (params );
87
+ relativeLayout .addView (photoView );
88
+ contactView .addView (relativeLayout );
89
+
90
+ var imageView = new ImageView (context );
91
+ imageView .setId (0x7FFF0001 );
92
+ var params2 = new RelativeLayout .LayoutParams (Utils .dipToPixels (14 ), Utils .dipToPixels (14 ));
93
+ params2 .addRule (RelativeLayout .ALIGN_TOP , contactView .getId ());
94
+ params2 .addRule (isLeftToRight ? RelativeLayout .ALIGN_RIGHT : RelativeLayout .ALIGN_LEFT , photoView .getId ());
95
+ params2 .topMargin = Utils .dipToPixels (5 );
96
+ imageView .setLayoutParams (params2 );
97
+ imageView .setImageResource (ResId .drawable .online );
98
+ imageView .setAdjustViewBounds (true );
99
+ imageView .setScaleType (ImageView .ScaleType .FIT_XY );
100
+ imageView .setVisibility (View .INVISIBLE );
101
+ relativeLayout .addView (imageView );
102
+ } else if (firstChild instanceof RelativeLayout relativeLayout ) {
103
+ var photoView = (ImageView ) relativeLayout .getChildAt (0 );
104
+
105
+ var params = new RelativeLayout .LayoutParams (LinearLayout .LayoutParams .WRAP_CONTENT , LinearLayout .LayoutParams .WRAP_CONTENT );
106
+ params .addRule (RelativeLayout .CENTER_IN_PARENT );
107
+ photoView .setLayoutParams (params );
108
+
109
+ var imageView = new ImageView (context );
110
+ imageView .setId (0x7FFF0001 );
111
+ var params2 = new RelativeLayout .LayoutParams (Utils .dipToPixels (14 ), Utils .dipToPixels (14 ));
112
+ params2 .addRule (RelativeLayout .ALIGN_TOP , contactView .getId ());
113
+ params2 .addRule (isLeftToRight ? RelativeLayout .ALIGN_RIGHT : RelativeLayout .ALIGN_LEFT , photoView .getId ());
114
+ params2 .topMargin = Utils .dipToPixels (5 );
115
+ imageView .setLayoutParams (params2 );
116
+ imageView .setImageResource (ResId .drawable .online );
117
+ imageView .setAdjustViewBounds (true );
118
+ imageView .setScaleType (ImageView .ScaleType .FIT_XY );
119
+ imageView .setVisibility (View .INVISIBLE );
120
+ relativeLayout .addView (imageView );
121
+ }
101
122
}
102
123
}
103
124
});
@@ -144,7 +165,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
144
165
145
166
var getAdapterPositionMethod = ReflectionUtils .findMethodUsingFilter (absViewHolderClass , method -> method .getParameterCount () == 0 && method .getReturnType () == int .class );
146
167
var position = (int ) ReflectionUtils .callMethod (getAdapterPositionMethod , viewHolder );
147
- ImageView csDot = showOnlineIcon ? view .findViewById (0x7FFF0003 ). findViewById ( 0x7FFF0001 ) : null ;
168
+ ImageView csDot = showOnlineIcon ? view .findViewById (0x7FFF0001 ) : null ;
148
169
if (showOnlineIcon ) {
149
170
csDot .setVisibility (View .INVISIBLE );
150
171
}
0 commit comments