mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-03 00:38:53 +00:00
Fix unfold menus soft-lock after tab is switched to another
This commit is contained in:
+6
-2
@@ -12,7 +12,7 @@ android {
|
||||
applicationId "ru.ytkab0bp.slicebeam"
|
||||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode 2
|
||||
versionCode 3
|
||||
versionName "0.1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
@@ -34,8 +34,12 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
buildConfigField "boolean", "IS_GOOGLE_PLAY", "true"
|
||||
buildConfigField "boolean", "IS_GOOGLE_PLAY", "false"
|
||||
buildConfigField "String", "COMMIT", "\"" + commit + "\""
|
||||
ndk {
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
}
|
||||
debug {
|
||||
buildConfigField "boolean", "IS_GOOGLE_PLAY", "false"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SliceMenu extends ListBedMenu {
|
||||
protected List<SimpleRecyclerItem> onCreateItems(boolean portrait) {
|
||||
lastUid = SliceBeam.CONFIG_UID;
|
||||
List<SimpleRecyclerItem> items = new ArrayList<>(Arrays.asList(
|
||||
new BedMenuItem(R.string.MenuSliceInfo, R.drawable.square_stack_up_outline_28).onClick(v -> fragment.showUnfoldMenu(new PrintInfoMenu(), v)),
|
||||
new BedMenuItem(R.string.MenuSliceInfo, R.drawable.square_stack_up_outline_28).onClick(v -> fragment.showUnfoldMenu(new LayersMenu(), v)),
|
||||
new BedMenuItem(R.string.MenuSliceExportToFile, R.drawable.folder_simple_arrow_right_outline_28).onClick(v -> {
|
||||
if (fragment.getContext() instanceof Activity) {
|
||||
Activity act = (Activity) fragment.getContext();
|
||||
@@ -176,7 +176,7 @@ public class SliceMenu extends ListBedMenu {
|
||||
});
|
||||
}
|
||||
|
||||
private final static class PrintInfoMenu extends UnfoldMenu {
|
||||
private final static class LayersMenu extends UnfoldMenu {
|
||||
private PositionScrollView fromTrack, toTrack;
|
||||
private TextView title;
|
||||
|
||||
|
||||
@@ -123,7 +123,10 @@ public class BedFragment extends Fragment {
|
||||
public void showUnfoldMenu(UnfoldMenu menu, View from) {
|
||||
if (currentUnfoldMenu != null) return;
|
||||
|
||||
menu.setOnDismiss(()-> currentUnfoldMenu = null);
|
||||
menu.setOnDismiss(()-> {
|
||||
if (menu.isAttached()) return;
|
||||
currentUnfoldMenu = null;
|
||||
});
|
||||
currentUnfoldMenu = menu;
|
||||
menu.show(from, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user