Open overview with header in track menu
This commit is contained in:
parent
6d0f17748f
commit
fba0b42119
4 changed files with 55 additions and 33 deletions
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.base;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.Animator.AnimatorListener;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
|
@ -884,10 +885,28 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
|||
updateMainViewLayout(posY);
|
||||
}
|
||||
if (animated) {
|
||||
mainView.animate().y(posY)
|
||||
.setDuration(ANIMATION_DURATION)
|
||||
.setInterpolator(new DecelerateInterpolator())
|
||||
.setListener(new AnimatorListenerAdapter() {
|
||||
animateMainView(posY, needCloseMenu, previousMenuState, newMenuState);
|
||||
} else {
|
||||
if (needCloseMenu && isHideable()) {
|
||||
dismiss();
|
||||
} else {
|
||||
mainView.setY(posY);
|
||||
updateMainViewLayout(posY);
|
||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextMenuFragmentListener listener = this.listener;
|
||||
if (listener != null) {
|
||||
listener.onContextMenuYPosChanged(this, posY, needMapAdjust, true);
|
||||
}
|
||||
}
|
||||
return posY;
|
||||
}
|
||||
|
||||
protected void animateMainView(final int posY, final boolean needCloseMenu, final int previousMenuState, final int newMenuState) {
|
||||
animateView(mainView, posY, new AnimatorListenerAdapter() {
|
||||
|
||||
boolean canceled = false;
|
||||
|
||||
|
@ -909,30 +928,14 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
|||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
if (needCloseMenu && isHideable()) {
|
||||
dismiss();
|
||||
} else {
|
||||
mainView.setY(posY);
|
||||
updateMainViewLayout(posY);
|
||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextMenuFragmentListener listener = this.listener;
|
||||
if (listener != null) {
|
||||
listener.onContextMenuYPosChanged(this, posY, needMapAdjust, true);
|
||||
}
|
||||
}
|
||||
return posY;
|
||||
});
|
||||
}
|
||||
|
||||
public void animateView(@NonNull View view, int y) {
|
||||
public void animateView(@NonNull View view, int y, @Nullable AnimatorListener listener) {
|
||||
view.animate().y(y)
|
||||
.setDuration(ANIMATION_DURATION)
|
||||
.setInterpolator(new DecelerateInterpolator())
|
||||
.setListener(listener)
|
||||
.start();
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl
|
|||
if (mapControlsView != null) {
|
||||
int zoomY = y - getMapControlsHeight();
|
||||
if (animated) {
|
||||
fragment.animateView(mapControlsView, zoomY);
|
||||
fragment.animateView(mapControlsView, zoomY, null);
|
||||
} else {
|
||||
mapControlsView.setY(zoomY);
|
||||
}
|
||||
|
|
|
@ -767,7 +767,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() +
|
||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0);
|
||||
if (animated) {
|
||||
fragment.animateView(pagesView, pagesY);
|
||||
fragment.animateView(pagesView, pagesY, null);
|
||||
} else {
|
||||
pagesView.setY(pagesY);
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
int zoomY = y - getZoomButtonsHeight() +
|
||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0);
|
||||
if (animated) {
|
||||
fragment.animateView(zoomButtonsView, zoomY);
|
||||
fragment.animateView(zoomButtonsView, zoomY, null);
|
||||
} else {
|
||||
zoomButtonsView.setY(zoomY);
|
||||
}
|
||||
|
|
|
@ -155,6 +155,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
private LatLon latLon;
|
||||
|
||||
private int menuTitleHeight;
|
||||
private int menuHeaderHeight;
|
||||
private int toolbarHeightPx;
|
||||
private boolean mapPositionAdjusted;
|
||||
|
||||
|
@ -300,8 +301,12 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
updateHeader();
|
||||
setupButtons(view);
|
||||
updateCardsLayout();
|
||||
if (menuType == TrackMenuType.OVERVIEW && isPortrait()) {
|
||||
calculateLayoutAndShowHeader();
|
||||
} else {
|
||||
calculateLayoutAndUpdateMenuState();
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -484,8 +489,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
|
||||
@Override
|
||||
protected void calculateLayout(View view, boolean initLayout) {
|
||||
menuTitleHeight = routeMenuTopShadowAll.getHeight()
|
||||
+ bottomNav.getHeight();
|
||||
menuHeaderHeight = headerContainer.getHeight();
|
||||
menuTitleHeight = routeMenuTopShadowAll.getHeight() + bottomNav.getHeight();
|
||||
super.calculateLayout(view, initLayout);
|
||||
}
|
||||
|
||||
|
@ -913,6 +918,20 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
});
|
||||
}
|
||||
|
||||
private void calculateLayoutAndShowHeader() {
|
||||
runLayoutListener(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int posY = getViewHeight() - menuHeaderHeight - menuTitleHeight - getShadowHeight();
|
||||
if (posY < getViewY()) {
|
||||
updateMainViewLayout(posY);
|
||||
}
|
||||
animateMainView(posY, false, getCurrentMenuState(), getCurrentMenuState());
|
||||
updateMapControlsPos(TrackMenuFragment.this, posY, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateMenuState() {
|
||||
if (menuType == TrackMenuType.OPTIONS) {
|
||||
openMenuFullScreen();
|
||||
|
|
Loading…
Reference in a new issue