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 {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -815,7 +815,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment
|
|||
|
||||
ContextMenuFragmentListener listener = this.listener;
|
||||
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;
|
||||
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
|
||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
|
||||
updateMapControlsVisibility(menuState);
|
||||
}
|
||||
|
||||
|
|
|
@ -815,7 +815,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState, int previousMenuState) {
|
||||
LockableViewPager viewPager = this.viewPager;
|
||||
RouteDetailsFragment current = getCurrentFragment();
|
||||
if (viewPager != null && fragment == current) {
|
||||
|
|
|
@ -152,6 +152,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
|
||||
private int menuTitleHeight;
|
||||
private int toolbarHeightPx;
|
||||
private boolean mapPositionAdjusted;
|
||||
|
||||
public enum TrackMenuType {
|
||||
OVERVIEW(R.id.action_overview, R.string.shared_string_overview),
|
||||
|
@ -455,9 +456,11 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
adjustMapPosition(getHeight());
|
||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int currentMenuState, int previousMenuState) {
|
||||
super.onContextMenuStateChanged(fragment, currentMenuState, previousMenuState);
|
||||
if (currentMenuState != MenuState.FULL_SCREEN && (currentMenuState != previousMenuState || !mapPositionAdjusted)) {
|
||||
adjustMapPosition(getViewY());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
@ -821,6 +815,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
if (r.left != 0 && r.right != 0) {
|
||||
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0);
|
||||
}
|
||||
mapPositionAdjusted = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue