Fix transport context menu

This commit is contained in:
Alexey Kulish 2017-08-04 19:45:36 +03:00
parent 1a9df71765
commit e7b7a98266
4 changed files with 35 additions and 20 deletions

View file

@ -498,6 +498,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return; return;
} }
} }
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
mapContextMenu.close();
return;
}
if (prevActivityIntent != null && getSupportFragmentManager().getBackStackEntryCount() == 0) { if (prevActivityIntent != null && getSupportFragmentManager().getBackStackEntryCount() == 0) {
prevActivityIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); prevActivityIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
LatLon loc = getMapLocation(); LatLon loc = getMapLocation();

View file

@ -379,15 +379,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
init(latLon, pointDescription, object, true, false); init(latLon, pointDescription, object, true, false);
if (fragmentRef != null) { if (fragmentRef != null) {
fragmentRef.get().rebuildMenu(); fragmentRef.get().rebuildMenu(centerMarker);
}
}
public void rebuildMenu() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().rebuildMenu();
} }
centerMarker = false;
} }
public void showOrUpdate(LatLon latLon, PointDescription pointDescription, Object object) { public void showOrUpdate(LatLon latLon, PointDescription pointDescription, Object object) {

View file

@ -792,7 +792,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
menu.setMapZoom(0); menu.setMapZoom(0);
} }
public void rebuildMenu() { public void rebuildMenu(boolean centered) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null && view != null) { if (app != null && view != null) {
IconsCache iconsCache = app.getIconsCache(); IconsCache iconsCache = app.getIconsCache();
@ -807,6 +807,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
bottomLayout.removeAllViews(); bottomLayout.removeAllViews();
buildBottomView(); buildBottomView();
if (centered) {
this.initLayout = true;
this.centered = true;
}
runLayoutListener(); runLayoutListener();
} }
} }
@ -1284,7 +1288,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public void downloadHasFinished() { public void downloadHasFinished() {
updateOnDownload(); updateOnDownload();
if (menu != null && menu.isVisible() && menu.isMapDownloaded()) { if (menu != null && menu.isVisible() && menu.isMapDownloaded()) {
rebuildMenu(); rebuildMenu(false);
} }
} }

View file

@ -101,8 +101,14 @@ public class TransportRouteController extends MenuController {
@Override @Override
public String getTypeStr() { public String getTypeStr() {
if (transportRoute.refStop != null) {
return transportRoute.refStop.getName();
} else if (transportRoute.stop != null) {
return transportRoute.stop.getName();
} else {
return getPointDescription().getTypeName(); return getPointDescription().getTypeName();
} }
}
@Override @Override
public void onShow() { public void onShow() {
@ -159,16 +165,23 @@ public class TransportRouteController extends MenuController {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
MapContextMenu menu = getMapActivity().getContextMenu(); if (mapContextMenu != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP, transportRoute.stop = stop;
getMapActivity().getString(R.string.transport_Stop), name); transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
transportRoute.getDescription(getMapActivity().getMyApplication(), false));
//resetRoute();
LatLon stopLocation = stop.getLocation(); LatLon stopLocation = stop.getLocation();
getMapActivity().getMyApplication().getSettings() if (mapContextMenu.isVisible()) {
.setMapLocationToShow(stopLocation.getLatitude(), stopLocation.getLongitude(), mapContextMenu.updateMapCenter(stopLocation);
15, pd, false, stop); } else {
MapActivity.launchMapActivityMoveToTop(getMapActivity()); mapContextMenu.setMapCenter(stopLocation);
mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition());
}
mapContextMenu.setCenterMarker(true);
mapContextMenu.setMapZoom(15);
mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute);
}
} }
}); });
} }