mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-19 01:27:18 -04:00
Fix[controls]: sub button visibility lifecycle
This commit is contained in:
parent
876c97fe2e
commit
3729230c42
@ -185,11 +185,12 @@ public class ControlLayout extends FrameLayout {
|
|||||||
view.setFocusable(false);
|
view.setFocusable(false);
|
||||||
view.setFocusableInTouchMode(false);
|
view.setFocusableInTouchMode(false);
|
||||||
}else{
|
}else{
|
||||||
view.setVisible(drawer.areButtonsVisible);
|
view.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawer.addButton(view);
|
|
||||||
addView(view);
|
addView(view);
|
||||||
|
drawer.addButton(view);
|
||||||
|
|
||||||
|
|
||||||
setModified(true);
|
setModified(true);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.kdt.pojavlaunch.customcontrols.buttons;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.kdt.pojavlaunch.Tools;
|
import net.kdt.pojavlaunch.Tools;
|
||||||
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
import net.kdt.pojavlaunch.customcontrols.ControlData;
|
||||||
@ -40,12 +41,12 @@ public class ControlDrawer extends ControlButton {
|
|||||||
|
|
||||||
public void addButton(ControlSubButton button){
|
public void addButton(ControlSubButton button){
|
||||||
buttons.add(button);
|
buttons.add(button);
|
||||||
setControlButtonVisibility(button, areButtonsVisible);
|
|
||||||
syncButtons();
|
syncButtons();
|
||||||
|
setControlButtonVisibility(button, areButtonsVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setControlButtonVisibility(ControlButton button, boolean isVisible){
|
private void setControlButtonVisibility(ControlButton button, boolean isVisible){
|
||||||
button.setVisible(isVisible);
|
post(() -> button.setVisible(isVisible));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchButtonVisibility(){
|
private void switchButtonVisibility(){
|
||||||
@ -124,10 +125,12 @@ public class ControlDrawer extends ControlButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean isVisible) {
|
public void setVisible(boolean isVisible) {
|
||||||
//TODO replicate changes to his children ?
|
int visibility = isVisible ? VISIBLE : GONE;
|
||||||
setVisibility(isVisible ? VISIBLE : GONE);
|
setVisibility(visibility);
|
||||||
if(!isVisible){
|
if(visibility == GONE || areButtonsVisible) {
|
||||||
areButtonsVisible = false;
|
for(ControlSubButton button : buttons){
|
||||||
|
button.setVisible(isVisible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,12 @@ public class ControlSubButton extends ControlButton {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean isVisible) {
|
public void setVisible(boolean isVisible) {
|
||||||
setVisibility(isVisible ? (parentDrawer.areButtonsVisible ? VISIBLE : GONE) : (!mProperties.isHideable && parentDrawer.getVisibility() == GONE) ? VISIBLE : View.GONE);
|
setVisibility(isVisible ? VISIBLE : (!mProperties.isHideable && parentDrawer.getVisibility() == GONE) ? VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGrabState(boolean isGrabbing) {
|
||||||
|
// STUB, visibility lifecycle handled by the ControlDrawer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user