This commit is contained in:
Alexey Kulish 2015-11-02 17:23:12 +03:00
parent be1e776d4a
commit 4cf05ed801
5 changed files with 29 additions and 16 deletions

View file

@ -163,14 +163,14 @@ public class MapContextMenu extends MenuTitleController {
public void close() { public void close() {
active = false; active = false;
if (this.object != null) {
clearSelectedObject(this.object);
}
hide(); hide();
mapActivity.getMapView().refreshMap(); mapActivity.getMapView().refreshMap();
} }
public void hide() { public void hide() {
if (this.object != null) {
clearSelectedObject(this.object);
}
if (mapPosition != 0) { if (mapPosition != 0) {
mapActivity.getMapView().setMapPosition(mapPosition); mapActivity.getMapView().setMapPosition(mapPosition);
mapPosition = 0; mapPosition = 0;

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; 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.ParkingPositionMenuController;
import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController; import net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController; 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.controllers.WptPtMenuController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.osmedit.OsmPoint; import net.osmand.plus.osmedit.OsmPoint;
@ -111,8 +112,8 @@ public abstract class MenuController extends BaseMenuController {
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object); menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) { } else if (object instanceof WptPt) {
menuController = new WptPtMenuController(app, mapActivity, (WptPt) object); menuController = new WptPtMenuController(app, mapActivity, (WptPt) object);
} else if (object instanceof WorldRegion) { } else if (object instanceof BinaryMapDataObject) {
menuController = new WorldRegionMenuController(app, mapActivity, (WorldRegion) object); menuController = new MapDataMenuController(app, mapActivity, (BinaryMapDataObject) object);
} else if (object instanceof LatLon) { } else if (object instanceof LatLon) {
if (pointDescription.isParking()) { if (pointDescription.isParking()) {
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription); menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);

View file

@ -3,8 +3,10 @@ package net.osmand.plus.mapcontextmenu.controllers;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import net.osmand.binary.BinaryMapDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.map.OsmandRegions;
import net.osmand.map.WorldRegion; import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
public class WorldRegionMenuController extends MenuController { public class MapDataMenuController extends MenuController {
private WorldRegion region; 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); super(new MenuBuilder(app), mapActivity);
OsmandRegions osmandRegions = app.getRegions();
String fullName = osmandRegions.getFullName(dataObject);
final WorldRegion region = osmandRegions.getRegionData(fullName);
this.region = region; this.region = region;
titleButtonController = new TitleButtonController() { titleButtonController = new TitleButtonController() {
@Override @Override

View file

@ -155,13 +155,13 @@ public class ObjectSelectionMenu extends BaseMenuController {
} }
public void onDismiss() { public void onDismiss() {
clearSelectedObjects();
} }
public void openContextMenu(MenuObject menuObject) { public void openContextMenu(MenuObject menuObject) {
if (selectedObjects.containsKey(menuObject.getObject())) { if (selectedObjects.containsKey(menuObject.getObject())) {
selectedObjects.remove(menuObject.getObject()); selectedObjects.remove(menuObject.getObject());
} }
clearSelectedObjects();
hide(getMapActivity()); hide(getMapActivity());
getMapActivity().getContextMenu() getMapActivity().getContextMenu()
.show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject()); .show(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject());

View file

@ -337,8 +337,12 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
@Override @Override
public LatLon getObjectLocation(Object o) { public LatLon getObjectLocation(Object o) {
if (o instanceof WorldRegion) { if (o instanceof BinaryMapDataObject) {
return ((WorldRegion) o).getRegionCenter(); String fullName = osmandRegions.getFullName((BinaryMapDataObject) o);
final WorldRegion region = osmandRegions.getRegionData(fullName);
if (region != null) {
return region.getRegionCenter();
}
} }
return null; return null;
} }
@ -364,7 +368,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
return false; 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(); int zoom = tb.getZoom();
if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized()) { if (zoom >= ZOOM_TO_SHOW_BORDERS_ST && zoom < ZOOM_TO_SHOW_BORDERS && osmandRegions.isInitialized()) {
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y); LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
@ -394,19 +398,22 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe
selectedObjects = result; selectedObjects = result;
for (BinaryMapDataObject o : result) { for (BinaryMapDataObject o : result) {
String fullName = osmandRegions.getFullName(o); dataObjects.add(o);
WorldRegion region = osmandRegions.getRegionData(fullName);
regions.add(region);
} }
} }
} }
@Override @Override
public void setSelectedObject(Object o) { public void setSelectedObject(Object o) {
if (o instanceof BinaryMapDataObject) {
List<BinaryMapDataObject> list = new LinkedList<>();
list.add((BinaryMapDataObject) o);
selectedObjects = list;
}
} }
@Override @Override
public void clearSelectedObject() { public void clearSelectedObject() {
//selectedObjects = null; selectedObjects = null;
} }
} }