From e2f35f3f6f8fd08ef6db240b2d693d7d40d6c8ef Mon Sep 17 00:00:00 2001 From: SerpentSpirale Date: Fri, 30 Apr 2021 11:46:48 +0200 Subject: [PATCH] Clean some code --- .../customcontrols/ControlButton.java | 4 +-- .../customcontrols/ControlLayout.java | 26 +++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java index 742b3ca25..7dce338f1 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/ControlButton.java @@ -271,8 +271,8 @@ public class ControlButton extends androidx.appcompat.widget.AppCompatButton imp } } - public void setModifiable(boolean z) { - mModifiable = z; + public void setModifiable(boolean isModifiable) { + mModifiable = isModifiable; } private void setModified(boolean modified) { 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 c71aa316d..3dee6dd7e 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,20 +44,12 @@ 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 { - removeAllViews();*/ - removeAllButtons(); - //} - if (mLayout != null) { - mLayout.mControlDataList = null; - mLayout = null; - } + removeAllButtons(); + if(mLayout != null) { + mLayout.mControlDataList = null; + mLayout = null; + } + System.gc(); // Cleanup buttons only when input layout is null @@ -70,8 +62,8 @@ public class ControlLayout extends FrameLayout button.width = button.width / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE; button.height = button.height / controlLayout.scaledAt * LauncherPreferences.PREF_BUTTONSIZE; if (!button.isDynamicBtn) { - button.dynamicX = Float.toString(button.x / CallbackBridge.physicalWidth) + " * ${screen_width}"; - button.dynamicY = Float.toString(button.y / CallbackBridge.physicalHeight) + " * ${screen_height}"; + button.dynamicX = button.x / CallbackBridge.physicalWidth + " * ${screen_width}"; + button.dynamicY = button.y / CallbackBridge.physicalHeight + " * ${screen_height}"; } button.update(); addControlView(button); @@ -138,7 +130,7 @@ public class ControlLayout extends FrameLayout for (int i = 0; i < getChildCount(); i++) { View view = getChildAt(i); if (view instanceof ControlButton && ((ControlButton) view).getProperties().isHideable) { - ((ControlButton) view).setVisibility(mControlVisible ? View.VISIBLE : View.GONE); + view.setVisibility(mControlVisible ? View.VISIBLE : View.GONE); } } }