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;
|
package net.osmand.plus.base;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.Animator.AnimatorListener;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -884,32 +885,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
||||||
updateMainViewLayout(posY);
|
updateMainViewLayout(posY);
|
||||||
}
|
}
|
||||||
if (animated) {
|
if (animated) {
|
||||||
mainView.animate().y(posY)
|
animateMainView(posY, needCloseMenu, previousMenuState, newMenuState);
|
||||||
.setDuration(ANIMATION_DURATION)
|
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
|
||||||
.setListener(new AnimatorListenerAdapter() {
|
|
||||||
|
|
||||||
boolean canceled = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationCancel(Animator animation) {
|
|
||||||
canceled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAnimationEnd(Animator animation) {
|
|
||||||
if (!canceled) {
|
|
||||||
if (needCloseMenu && isHideable()) {
|
|
||||||
dismiss();
|
|
||||||
} else {
|
|
||||||
updateMainViewLayout(posY);
|
|
||||||
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
|
||||||
doAfterMenuStateChange(previousMenuState, newMenuState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
} else {
|
} else {
|
||||||
if (needCloseMenu && isHideable()) {
|
if (needCloseMenu && isHideable()) {
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -929,10 +905,37 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
||||||
return posY;
|
return posY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void animateView(@NonNull View view, int y) {
|
protected void animateMainView(final int posY, final boolean needCloseMenu, final int previousMenuState, final int newMenuState) {
|
||||||
|
animateView(mainView, posY, new AnimatorListenerAdapter() {
|
||||||
|
|
||||||
|
boolean canceled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
canceled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
if (!canceled) {
|
||||||
|
if (needCloseMenu && isHideable()) {
|
||||||
|
dismiss();
|
||||||
|
} else {
|
||||||
|
updateMainViewLayout(posY);
|
||||||
|
if (previousMenuState != 0 && newMenuState != 0 && previousMenuState != newMenuState) {
|
||||||
|
doAfterMenuStateChange(previousMenuState, newMenuState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animateView(@NonNull View view, int y, @Nullable AnimatorListener listener) {
|
||||||
view.animate().y(y)
|
view.animate().y(y)
|
||||||
.setDuration(ANIMATION_DURATION)
|
.setDuration(ANIMATION_DURATION)
|
||||||
.setInterpolator(new DecelerateInterpolator())
|
.setInterpolator(new DecelerateInterpolator())
|
||||||
|
.setListener(listener)
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl
|
||||||
if (mapControlsView != null) {
|
if (mapControlsView != null) {
|
||||||
int zoomY = y - getMapControlsHeight();
|
int zoomY = y - getMapControlsHeight();
|
||||||
if (animated) {
|
if (animated) {
|
||||||
fragment.animateView(mapControlsView, zoomY);
|
fragment.animateView(mapControlsView, zoomY, null);
|
||||||
} else {
|
} else {
|
||||||
mapControlsView.setY(zoomY);
|
mapControlsView.setY(zoomY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -767,7 +767,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() +
|
int pagesY = y - getPagesViewHeight() + fragment.getShadowHeight() +
|
||||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0);
|
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(pagesView.getContext()) : 0);
|
||||||
if (animated) {
|
if (animated) {
|
||||||
fragment.animateView(pagesView, pagesY);
|
fragment.animateView(pagesView, pagesY, null);
|
||||||
} else {
|
} else {
|
||||||
pagesView.setY(pagesY);
|
pagesView.setY(pagesY);
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
int zoomY = y - getZoomButtonsHeight() +
|
int zoomY = y - getZoomButtonsHeight() +
|
||||||
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0);
|
(Build.VERSION.SDK_INT >= 21 ? AndroidUtils.getStatusBarHeight(zoomButtonsView.getContext()) : 0);
|
||||||
if (animated) {
|
if (animated) {
|
||||||
fragment.animateView(zoomButtonsView, zoomY);
|
fragment.animateView(zoomButtonsView, zoomY, null);
|
||||||
} else {
|
} else {
|
||||||
zoomButtonsView.setY(zoomY);
|
zoomButtonsView.setY(zoomY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
private LatLon latLon;
|
private LatLon latLon;
|
||||||
|
|
||||||
private int menuTitleHeight;
|
private int menuTitleHeight;
|
||||||
|
private int menuHeaderHeight;
|
||||||
private int toolbarHeightPx;
|
private int toolbarHeightPx;
|
||||||
private boolean mapPositionAdjusted;
|
private boolean mapPositionAdjusted;
|
||||||
|
|
||||||
|
@ -300,7 +301,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
updateHeader();
|
updateHeader();
|
||||||
setupButtons(view);
|
setupButtons(view);
|
||||||
updateCardsLayout();
|
updateCardsLayout();
|
||||||
calculateLayoutAndUpdateMenuState();
|
if (menuType == TrackMenuType.OVERVIEW && isPortrait()) {
|
||||||
|
calculateLayoutAndShowHeader();
|
||||||
|
} else {
|
||||||
|
calculateLayoutAndUpdateMenuState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -484,8 +489,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void calculateLayout(View view, boolean initLayout) {
|
protected void calculateLayout(View view, boolean initLayout) {
|
||||||
menuTitleHeight = routeMenuTopShadowAll.getHeight()
|
menuHeaderHeight = headerContainer.getHeight();
|
||||||
+ bottomNav.getHeight();
|
menuTitleHeight = routeMenuTopShadowAll.getHeight() + bottomNav.getHeight();
|
||||||
super.calculateLayout(view, initLayout);
|
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() {
|
private void updateMenuState() {
|
||||||
if (menuType == TrackMenuType.OPTIONS) {
|
if (menuType == TrackMenuType.OPTIONS) {
|
||||||
openMenuFullScreen();
|
openMenuFullScreen();
|
||||||
|
|
Loading…
Reference in a new issue