Fix first map position adjusting
This commit is contained in:
parent
0d67fb55ba
commit
c7f5edca55
4 changed files with 13 additions and 17 deletions
|
@ -103,7 +103,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
||||||
|
|
||||||
public interface ContextMenuFragmentListener {
|
public interface ContextMenuFragmentListener {
|
||||||
void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated);
|
void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated);
|
||||||
void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState);
|
void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState);
|
||||||
void onContextMenuDismiss(@NonNull ContextMenuFragment fragment);
|
void onContextMenuDismiss(@NonNull ContextMenuFragment fragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,7 +815,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
||||||
|
|
||||||
ContextMenuFragmentListener listener = this.listener;
|
ContextMenuFragmentListener listener = this.listener;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onContextMenuStateChanged(this, newMenuState);
|
listener.onContextMenuStateChanged(this, newMenuState, currentMenuState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -971,7 +971,8 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
||||||
|
|
||||||
ContextMenuFragmentListener listener = ContextMenuFragment.this.listener;
|
ContextMenuFragmentListener listener = ContextMenuFragment.this.listener;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onContextMenuStateChanged(ContextMenuFragment.this, getCurrentMenuState());
|
int menuState = getCurrentMenuState();
|
||||||
|
listener.onContextMenuStateChanged(ContextMenuFragment.this, menuState, menuState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public abstract class ContextMenuScrollFragment extends ContextMenuFragment impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
|
||||||
updateMapControlsVisibility(menuState);
|
updateMapControlsVisibility(menuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -815,7 +815,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
|
||||||
LockableViewPager viewPager = this.viewPager;
|
LockableViewPager viewPager = this.viewPager;
|
||||||
RouteDetailsFragment current = getCurrentFragment();
|
RouteDetailsFragment current = getCurrentFragment();
|
||||||
if (viewPager != null && fragment == current) {
|
if (viewPager != null && fragment == current) {
|
||||||
|
|
|
@ -152,6 +152,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
|
|
||||||
private int menuTitleHeight;
|
private int menuTitleHeight;
|
||||||
private int toolbarHeightPx;
|
private int toolbarHeightPx;
|
||||||
|
private boolean mapPositionAdjusted;
|
||||||
|
|
||||||
public enum TrackMenuType {
|
public enum TrackMenuType {
|
||||||
OVERVIEW(R.id.action_overview, R.string.shared_string_overview),
|
OVERVIEW(R.id.action_overview, R.string.shared_string_overview),
|
||||||
|
@ -455,9 +456,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int currentMenuState, int previousMenuState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onContextMenuStateChanged(fragment, currentMenuState, previousMenuState);
|
||||||
adjustMapPosition(getHeight());
|
if (currentMenuState != MenuState.FULL_SCREEN && (currentMenuState != previousMenuState || !mapPositionAdjusted)) {
|
||||||
|
adjustMapPosition(getViewY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -760,15 +763,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int applyPosY(int currentY, boolean needCloseMenu, boolean needMapAdjust, int previousMenuState, int newMenuState, int dZoom, boolean animated) {
|
|
||||||
int y = super.applyPosY(currentY, needCloseMenu, needMapAdjust, previousMenuState, newMenuState, dZoom, animated);
|
|
||||||
if (needMapAdjust) {
|
|
||||||
adjustMapPosition(y);
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateToolbar(int y, boolean animated) {
|
public void updateToolbar(int y, boolean animated) {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
@ -821,6 +815,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
if (r.left != 0 && r.right != 0) {
|
if (r.left != 0 && r.right != 0) {
|
||||||
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
|
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
|
||||||
}
|
}
|
||||||
|
mapPositionAdjusted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue