@@ -59,6 +59,9 @@ public class XposedTaobaoPlugin {
5959 private Activity mCurrentActivity ;
6060
6161 private boolean mIsViewTreeObserverFirst ;
62+ private LinearLayout mItemHlinearLayout ;
63+ private LinearLayout mLineTopCon ;
64+ private View mLineBottomView ;
6265
6366 @ Keep
6467 public void main (final Context context , final XC_LoadPackage .LoadPackageParam lpparam ) {
@@ -306,7 +309,6 @@ private void doSettingsMenuInject(final Activity activity) {
306309 return ;
307310 }
308311 View itemView = ViewUtil .findViewByName (activity , activity .getPackageName (), "v_setting_page_item" );
309-
310312 LinearLayout linearLayout = (LinearLayout ) itemView .getParent ();
311313 linearLayout .setPadding (0 , 0 , 0 , 0 );
312314 List <ViewGroup .LayoutParams > childViewParamsList = new ArrayList <>();
@@ -320,21 +322,30 @@ private void doSettingsMenuInject(final Activity activity) {
320322
321323 linearLayout .removeAllViews ();
322324
323- LinearLayout lineTopCon = new LinearLayout (activity );
324- lineTopCon .setPadding (DpUtil .dip2px (activity , 12 ), 0 , 0 , 0 );
325- lineTopCon .setBackgroundColor (Color .WHITE );
325+ if (mLineTopCon == null ) {
326+ mLineTopCon = new LinearLayout (activity );
327+ } else {
328+ ViewUtil .removeFromSuperView (mLineTopCon );
329+ }
330+ mLineTopCon .setPadding (DpUtil .dip2px (activity , 12 ), 0 , 0 , 0 );
331+ mLineTopCon .setBackgroundColor (Color .WHITE );
326332
327333 View lineTopView = new View (activity );
328334 lineTopView .setBackgroundColor (0xFFDFDFDF );
329- lineTopCon .addView (lineTopView , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , 1 ));
335+ mLineTopCon .addView (lineTopView , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , 1 ));
330336
331- LinearLayout itemHlinearLayout = new LinearLayout (activity );
332- itemHlinearLayout .setOrientation (LinearLayout .HORIZONTAL );
333- itemHlinearLayout .setWeightSum (1 );
334- itemHlinearLayout .setBackground (ViewUtil .genBackgroundDefaultDrawable (Color .WHITE ));
335- itemHlinearLayout .setGravity (Gravity .CENTER_VERTICAL );
336- itemHlinearLayout .setClickable (true );
337- itemHlinearLayout .setOnClickListener (view -> new SettingsView (activity ).showInDialog ());
337+ if (mItemHlinearLayout == null ) {
338+ mItemHlinearLayout = new LinearLayout (activity );
339+ } else {
340+ ViewUtil .removeFromSuperView (mItemHlinearLayout );
341+ mItemHlinearLayout .removeAllViews ();
342+ }
343+ mItemHlinearLayout .setOrientation (LinearLayout .HORIZONTAL );
344+ mItemHlinearLayout .setWeightSum (1 );
345+ mItemHlinearLayout .setBackground (ViewUtil .genBackgroundDefaultDrawable (Color .WHITE ));
346+ mItemHlinearLayout .setGravity (Gravity .CENTER_VERTICAL );
347+ mItemHlinearLayout .setClickable (true );
348+ mItemHlinearLayout .setOnClickListener (view -> new SettingsView (activity ).showInDialog ());
338349
339350
340351 TextView itemNameText = new TextView (activity );
@@ -368,17 +379,21 @@ private void doSettingsMenuInject(final Activity activity) {
368379 L .e (e );
369380 }
370381
371- itemHlinearLayout .addView (itemNameText , new LinearLayout .LayoutParams (0 , ViewGroup .LayoutParams .MATCH_PARENT , 1 ));
372- itemHlinearLayout .addView (itemSummerText , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .MATCH_PARENT ));
382+ mItemHlinearLayout .addView (itemNameText , new LinearLayout .LayoutParams (0 , ViewGroup .LayoutParams .MATCH_PARENT , 1 ));
383+ mItemHlinearLayout .addView (itemSummerText , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .MATCH_PARENT ));
373384
374- View lineBottomView = new View (activity );
375- lineBottomView .setBackgroundColor (0xFFDFDFDF );
385+ if (mLineBottomView == null ) {
386+ mLineBottomView = new View (activity );
387+ } else {
388+ ViewUtil .removeFromSuperView (mLineBottomView );
389+ }
390+ mLineBottomView .setBackgroundColor (0xFFDFDFDF );
376391
377- linearLayout .addView (lineTopCon , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .WRAP_CONTENT ));
378- linearLayout .addView (itemHlinearLayout , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , DpUtil .dip2px (activity , 44 )));
392+ linearLayout .addView (mLineTopCon , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , ViewGroup .LayoutParams .WRAP_CONTENT ));
393+ linearLayout .addView (mItemHlinearLayout , new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , DpUtil .dip2px (activity , 44 )));
379394 LinearLayout .LayoutParams lineParams = new LinearLayout .LayoutParams (ViewGroup .LayoutParams .MATCH_PARENT , 1 );
380395 lineParams .bottomMargin = DpUtil .dip2px (activity , 10 );
381- linearLayout .addView (lineBottomView , lineParams );
396+ linearLayout .addView (mLineBottomView , lineParams );
382397
383398 for (int i = 0 ; i < childViewCount ; i ++) {
384399 View view = childViewList .get (i );
0 commit comments