From 0b41acac2b39f5e0acbdb549f056e15a4b05e02b Mon Sep 17 00:00:00 2001 From: artdeell Date: Mon, 8 Mar 2021 19:28:18 +0300 Subject: [PATCH] Optimize the view remover procedure to fix the lag in builds with Ingame Custom Controls --- .../customcontrols/ControlLayout.java | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java index f9d392897..cc5dac562 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlLayout.java @@ -44,13 +44,14 @@ public class ControlLayout extends FrameLayout if (mModifiable) { hideAllHandleViews(); } - //if (getChildAt(0) instanceof MinecraftGLView) { - // View viewGL = getChildAt(0); - // View viewTouchpad = getChildAt(1); - // removeAllViews(); - // addView(viewGL); - // addView(viewTouchpad); - //} else { + /*if (getChildAt(0) instanceof MinecraftGLView) { + View viewGL = getChildAt(0); + View viewTouchpad = getChildAt(1); + removeAllViews(); + addView(viewGL); + addView(viewTouchpad); + } else { + removeAllViews();*/ removeAllButtons(); //} if (mLayout != null) { @@ -99,13 +100,14 @@ public class ControlLayout extends FrameLayout } private void removeAllButtons() { List viewList = new ArrayList<>(); + View v; for(int i = 0; i < getChildCount(); i++) { - viewList.add(getChildAt(i)); + v = getChildAt(i); + if(v instanceof ControlButton) viewList.add(v); } - for(View v : viewList) { - if(v instanceof ControlButton) { - removeView(v); - } + v = null; + for(View v2 : viewList) { + removeView(v2); } viewList = null; System.gc();