Zoom to route after show on map pressed

This commit is contained in:
crimean 2019-04-13 18:37:41 +03:00
parent 431a1a9863
commit 91a13bf751
3 changed files with 35 additions and 16 deletions

View file

@ -79,6 +79,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
public static final String ROUTE_INFO_STATE_KEY = "route_info_state_key";
public static final String INITIAL_MENU_STATE_KEY = "initial_menu_state_key";
public static final String USE_ROUTE_INFO_MENU_KEY = "use_route_info_menu_key";
public static final String ADJUST_MAP_KEY = "adjust_map_key";
@Nullable
private LockableViewPager viewPager;
@ -103,6 +104,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
private boolean publicTransportMode;
private boolean useRouteInfoMenu;
private boolean openingAnalyseOnMap = false;
private boolean needAdjustMap;
@Nullable
@Override
@ -119,6 +121,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
if (args != null) {
routeIndex = args.getInt(ROUTE_INDEX_KEY);
useRouteInfoMenu = args.getBoolean(USE_ROUTE_INFO_MENU_KEY, false);
needAdjustMap = args.getBoolean(ADJUST_MAP_KEY, false);
initialMenuState = args.getInt(INITIAL_MENU_STATE_KEY, initialMenuState);
}
routesCount = 1;
@ -816,6 +819,10 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
updatePagesViewVisibility(menuState);
updateZoomButtonsVisibility(menuState);
updateViewPager(fragment.getViewY());
if (needAdjustMap) {
needAdjustMap = false;
f.showRouteOnMap();
}
}
}
}
@ -846,14 +853,14 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
}
}
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex,
boolean useRouteInfoMenu, int initialMenuState) {
static boolean showFromRouteInfo(FragmentManager fragmentManager, int routeIndex, int initialMenuState) {
try {
ChooseRouteFragment fragment = new ChooseRouteFragment();
Bundle args = new Bundle();
args.putInt(ROUTE_INDEX_KEY, routeIndex);
args.putBoolean(USE_ROUTE_INFO_MENU_KEY, useRouteInfoMenu);
args.putBoolean(USE_ROUTE_INFO_MENU_KEY, true);
args.putInt(INITIAL_MENU_STATE_KEY, initialMenuState);
args.putBoolean(ADJUST_MAP_KEY, initialMenuState != MenuState.FULL_SCREEN);
fragment.setArguments(args);
fragmentManager.beginTransaction()
.add(R.id.routeMenuContainer, fragment, TAG)

View file

@ -601,7 +601,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (mapActivity != null) {
if (card instanceof SimpleRouteCard) {
hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, true, MenuState.FULL_SCREEN);
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
}
}
}
@ -626,15 +626,14 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (buttonIndex == PublicTransportCard.DETAILS_BUTTON_INDEX) {
hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
((PublicTransportCard) card).getRouteId(), true, MenuState.FULL_SCREEN);
((PublicTransportCard) card).getRouteId(), MenuState.FULL_SCREEN);
} else if (buttonIndex == PublicTransportCard.SHOW_BUTTON_INDEX) {
setupCards();
openMenuHeaderOnly();
}
} else if (card instanceof SimpleRouteCard) {
hide();
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0,
true, MenuState.FULL_SCREEN);
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(), 0, MenuState.FULL_SCREEN);
}
}
}
@ -1325,7 +1324,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
if (app.getRoutingHelper().isPublicTransportMode()) {
if (isTransportRouteCalculated()) {
ChooseRouteFragment.showFromRouteInfo(mapActivity.getSupportFragmentManager(),
app.getTransportRoutingHelper().getCurrentRoute(), true, MenuState.HEADER_ONLY);
app.getTransportRoutingHelper().getCurrentRoute(), MenuState.HEADER_ONLY);
}
} else {
mapActivity.getMapLayers().getMapControlsLayer().startNavigation();

View file

@ -620,6 +620,21 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
((ViewGroup) view).addView(baseItemView);
}
public void showRouteOnMap() {
OsmandApplication app = requireMyApplication();
if (transportCard == null) {
RouteCalculationResult route = app.getRoutingHelper().getRoute();
if (route != null) {
showRouteOnMap(route);
}
} else {
TransportRouteResult route = app.getTransportRoutingHelper().getCurrentRouteResult();
if (route != null) {
showRouteOnMap(route);
}
}
}
public void showRouteOnMap(@NonNull RouteCalculationResult result) {
QuadRect rect = result.getLocationsRect();
if (rect != null) {
@ -644,14 +659,12 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
public void showRouteOnMap(TransportRouteResult result) {
if (result != null) {
OsmandApplication app = requireMyApplication();
QuadRect rect = app.getTransportRoutingHelper().getTransportRouteRect(result);
if (rect != null) {
openMenuHeaderOnly();
fitRectOnMap(rect);
}
public void showRouteOnMap(@NonNull TransportRouteResult result) {
OsmandApplication app = requireMyApplication();
QuadRect rect = app.getTransportRoutingHelper().getTransportRouteRect(result);
if (rect != null) {
openMenuHeaderOnly();
fitRectOnMap(rect);
}
}