Button container, button gone fix

This commit is contained in:
VancedOfficial 2022-01-26 00:32:26 +02:00
parent c7cc47baf0
commit 0ed0e7d0e7

View File

@ -20,6 +20,7 @@ public abstract class SlimButton implements View.OnClickListener {
private final ViewGroup container;
protected final ImageView button_icon;
protected final TextView button_text;
private boolean viewAdded = false;
static {
SLIM_METADATA_BUTTON_ID = VancedUtils.getIdentifier("slim_metadata_button", "layout");
@ -36,14 +37,25 @@ public abstract class SlimButton implements View.OnClickListener {
button_text = (TextView)view.findViewById(VancedUtils.getIdentifier("button_text", "id"));
view.setOnClickListener(this);
setVisible(visible);
container.addView(view);
setVisible(visible);
}
public void setVisible(boolean visible) {
view.setVisibility(visible ? View.VISIBLE : View.GONE);
setContainerVisibility();
try {
if (!viewAdded && visible) {
container.addView(view);
viewAdded = true;
}
else if (viewAdded && !visible) {
container.removeView(view);
viewAdded = false;
}
setContainerVisibility();
}
catch (Exception ex) {
Log.e(TAG, "Error while changing button visibility", ex);
}
}
private void setContainerVisibility() {