Add default height states for gpx menu tabs

This commit is contained in:
Vitaliy 2021-01-27 19:27:00 +02:00
parent b3a712c47a
commit 12c3851c5b
2 changed files with 38 additions and 1 deletions

View file

@ -946,6 +946,11 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
protected void runLayoutListener() {
runLayoutListener(null);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
protected void runLayoutListener(final Runnable runnable) {
if (view != null) {
ViewTreeObserver vto = view.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@ -974,6 +979,9 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
int menuState = getCurrentMenuState();
listener.onContextMenuStateChanged(ContextMenuFragment.this, menuState, menuState);
}
if (runnable != null) {
runnable.run();
}
}
}
});

View file

@ -270,7 +270,18 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
setupToolbar();
updateHeader();
setupButtons(view);
runLayoutListener();
runLayoutListener(new Runnable() {
@Override
public void run() {
if (menuType == TrackMenuType.OPTIONS) {
openMenuFullScreen();
} else if (menuType == TrackMenuType.OVERVIEW) {
openMenuHeaderOnly();
} else {
openMenuHalfScreen();
}
}
});
}
return view;
}
@ -837,6 +848,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
menuType = type;
setupCards();
updateHeader();
updateMenuState();
break;
}
}
@ -845,6 +857,23 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
});
}
private void updateMenuState() {
runLayoutListener(new Runnable() {
@Override
public void run() {
if (menuType == TrackMenuType.OPTIONS) {
openMenuFullScreen();
} else if (menuType == TrackMenuType.OVERVIEW) {
openMenuHeaderOnly();
} else {
openMenuHalfScreen();
}
}
});
}
@Override
public void updateContent() {
if (segmentsCard != null) {