mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-03 08:39:04 +00:00
Fix unfold menus soft-lock after tab is switched to another
This commit is contained in:
@@ -27,6 +27,7 @@ public abstract class UnfoldMenu {
|
||||
protected BedFragment fragment;
|
||||
|
||||
private boolean isVisible;
|
||||
private boolean isDismissing;
|
||||
private SpringAnimation spring;
|
||||
private DynamicAnimation.OnAnimationUpdateListener updateListener;
|
||||
private FrameLayout containerLayout;
|
||||
@@ -121,13 +122,21 @@ public abstract class UnfoldMenu {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
|
||||
if (isVisible) {
|
||||
onCreate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
if (isVisible) {
|
||||
onDestroy();
|
||||
isVisible = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -138,7 +147,6 @@ public abstract class UnfoldMenu {
|
||||
rootView.setTranslationX(fromTranslationX);
|
||||
rootView.setTranslationY(fromTranslationY);
|
||||
|
||||
onCreate();
|
||||
dimmView = new View(ctx);
|
||||
dimmView.setBackgroundColor(0x40000000);
|
||||
dimmView.setTranslationX(toTranslationX);
|
||||
@@ -207,6 +215,10 @@ public abstract class UnfoldMenu {
|
||||
updateListener.onAnimationUpdate(spring, 1f, 0f);
|
||||
}
|
||||
|
||||
public boolean isAttached() {
|
||||
return rootView.getParent() != null && !isDismissing;
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
dismiss(false);
|
||||
}
|
||||
@@ -215,7 +227,9 @@ public abstract class UnfoldMenu {
|
||||
if (!isVisible) return;
|
||||
this.isVisible = false;
|
||||
|
||||
isDismissing = true;
|
||||
onDestroy();
|
||||
isDismissing = false;
|
||||
|
||||
if (alphaOnly) {
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
|
||||
|
||||
Reference in New Issue
Block a user