Fix transport context menu

This commit is contained in:
Alexey Kulish 2017-08-04 19:26:06 +03:00
parent 5e490e7c8b
commit f4b09e2b4d
4 changed files with 37 additions and 22 deletions

View file

@ -505,6 +505,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
getMeasurementToolFragment().showQuitDialog();
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

@ -10,13 +10,11 @@ import net.osmand.data.TransportStop;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.views.TransportStopsLayer;
import java.lang.ref.WeakReference;
import java.util.List;
public class TransportRouteController extends MenuController {
@ -94,14 +92,13 @@ public class TransportRouteController extends MenuController {
return false;
}
@Override
public boolean displayStreetNameInTitle() {
return super.displayStreetNameInTitle();
}
@Override
public String getTypeStr() {
return getPointDescription().getTypeName();
if (transportRoute.refStop != null) {
return transportRoute.refStop.getName();
} else {
return getPointDescription().getTypeName();
}
}
@Override
@ -159,16 +156,32 @@ public class TransportRouteController extends MenuController {
@Override
public void onClick(View arg0) {
MapContextMenu menu = getMapActivity().getContextMenu();
if (mapContextMenu != null) {
transportRoute.stop = stop;
transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
transportRoute.getDescription(getMapActivity().getMyApplication(), false));
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);
}
/*
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
getMapActivity().getString(R.string.transport_Stop), name);
//resetRoute();
LatLon stopLocation = stop.getLocation();
getMapActivity().getMyApplication().getSettings()
.setMapLocationToShow(stopLocation.getLatitude(), stopLocation.getLongitude(),
15, pd, false, stop);
15, pd, false, transportRoute);
MapActivity.launchMapActivityMoveToTop(getMapActivity());
*/
}
});
}