Fix
This commit is contained in:
parent
be1e776d4a
commit
4cf05ed801
5 changed files with 29 additions and 16 deletions
|
@ -163,14 +163,14 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
public void close() {
|
||||
active = false;
|
||||
if (this.object != null) {
|
||||
clearSelectedObject(this.object);
|
||||
}
|
||||
hide();
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
if (this.object != null) {
|
||||
clearSelectedObject(this.object);
|
||||
}
|
||||
if (mapPosition != 0) {
|
||||
mapActivity.getMapView().setMapPosition(mapPosition);
|
||||
mapPosition = 0;
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -25,7 +26,7 @@ import net.osmand.plus.mapcontextmenu.controllers.OsMoMenuController;
|
|||
import net.osmand.plus.mapcontextmenu.controllers.ParkingPositionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.WorldRegionMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
||||
import net.osmand.plus.mapcontextmenu.other.ShareMenu;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
|
@ -111,8 +112,8 @@ public abstract class MenuController extends BaseMenuController {
|
|||
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
|
||||
} else if (object instanceof WptPt) {
|
||||
menuController = new WptPtMenuController(app, mapActivity, (WptPt) object);
|
||||
} else if (object instanceof WorldRegion) {
|
||||
menuController = new WorldRegionMenuController(app, mapActivity, (WorldRegion) object);
|
||||
} else if (object instanceof BinaryMapDataObject) {
|
||||
menuController = new MapDataMenuController(app, mapActivity, (BinaryMapDataObject) object);
|
||||
} else if (object instanceof LatLon) {
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
|
||||
|
|
|
@ -3,8 +3,10 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -13,11 +15,14 @@ import net.osmand.plus.download.DownloadActivity;
|
|||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
|
||||
public class WorldRegionMenuController extends MenuController {
|
||||
public class MapDataMenuController extends MenuController {
|
||||
private WorldRegion region;
|
||||
|
||||
public WorldRegionMenuController(OsmandApplication app, MapActivity mapActivity, final WorldRegion region) {
|
||||
public MapDataMenuController(OsmandApplication app, MapActivity mapActivity, final BinaryMapDataObject dataObject) {
|
||||
super(new MenuBuilder(app), mapActivity);
|
||||
OsmandRegions osmandRegions = app.getRegions();
|
||||
String fullName = osmandRegions.getFullName(dataObject);
|
||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
this.region = region;
|
||||
titleButtonController = new TitleButtonController() {
|
||||
@Override
|
|
@ -155,13 +155,13 @@ public class ObjectSelectionMenu extends BaseMenuController {
|
|||
}
|
||||
|
||||
public void onDismiss() {
|
||||
clearSelectedObjects();
|
||||
}
|
||||
|
||||
public void openContextMenu(MenuObject menuObject) {
|
||||
if (selectedObjects.containsKey(menuObject.getObject())) {
|
||||
selectedObjects.remove(menuObject.getObject());
|
||||
}
|
||||
clearSelectedObjects();
|
||||
hide(getMapActivity());
|
||||
getMapActivity().getContextMenu()
|
||||
.show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());
|
||||
|
|
|
@ -337,8 +337,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
|
||||
@Override
|
||||
public LatLon getObjectLocation(Object o) {
|
||||
if (o instanceof WorldRegion) {
|
||||
return ((WorldRegion) o).getRegionCenter();
|
||||
if (o instanceof BinaryMapDataObject) {
|
||||
String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
|
||||
final WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
if (region != null) {
|
||||
return region.getRegionCenter();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -364,7 +368,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
return false;
|
||||
}
|
||||
|
||||
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super WorldRegion> regions) {
|
||||
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super BinaryMapDataObject> dataObjects) {
|
||||
int zoom = tb.getZoom();
|
||||
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized()) {
|
||||
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
|
||||
|
@ -394,19 +398,22 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
|
|||
selectedObjects = result;
|
||||
|
||||
for (BinaryMapDataObject o : result) {
|
||||
String fullName = osmandRegions.getFullName(o);
|
||||
WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
regions.add(region);
|
||||
dataObjects.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedObject(Object o) {
|
||||
if (o instanceof BinaryMapDataObject) {
|
||||
List<BinaryMapDataObject> list = new LinkedList<>();
|
||||
list.add((BinaryMapDataObject) o);
|
||||
selectedObjects = list;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSelectedObject() {
|
||||
//selectedObjects = null;
|
||||
selectedObjects = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue