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;
}
}
if (mapContextMenu.isVisible() && mapContextMenu.isClosable()) {
mapContextMenu.close();
return;
}
if (prevActivityIntent != null && getSupportFragmentManager().getBackStackEntryCount() == 0) {
prevActivityIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
LatLon loc = getMapLocation();

View file

@ -379,15 +379,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
init(latLon, pointDescription, object, true, false);
if (fragmentRef != null) {
fragmentRef.get().rebuildMenu();
}
}
public void rebuildMenu() {
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().rebuildMenu();
fragmentRef.get().rebuildMenu(centerMarker);
}
centerMarker = false;
}
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);
}
public void rebuildMenu() {
public void rebuildMenu(boolean centered) {
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
IconsCache iconsCache = app.getIconsCache();
@ -807,6 +807,10 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
bottomLayout.removeAllViews();
buildBottomView();
if (centered) {
this.initLayout = true;
this.centered = true;
}
runLayoutListener();
}
}
@ -1284,7 +1288,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public void downloadHasFinished() {
updateOnDownload();
if (menu != null && menu.isVisible() && menu.isMapDownloaded()) {
rebuildMenu();
rebuildMenu(false);
}
}

View file

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