Fixes (poi type and favorites show on map crash)

This commit is contained in:
Alexey Kulish 2015-10-12 10:49:57 +03:00
parent f464673fad
commit c635b8869d
6 changed files with 39 additions and 19 deletions

View file

@ -545,13 +545,13 @@ public class MapActivity extends AccessibleActivity {
dashboardOnMap.hideDashboard();
}
if (mapLabelToShow != null) {
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
if (toShow instanceof FavouritePoint) {
mapLayers.getContextMenuLayer().showContextMenuForSelectedObjects(latLonToShow);
} else {
// mapLayers.getContextMenuLayer().setSelectedObject(toShow);
// if (toShow instanceof FavouritePoint) {
// mapLayers.getContextMenuLayer().showContextMenuForSelectedObjects(latLonToShow);
// } else {
mapLayers.getContextMenuLayer().setLocation(latLonToShow,
mapLabelToShow.getFullPlainName(this));
}
// }
}
if (!latLonToShow.equals(cur)) {
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),

View file

@ -424,15 +424,15 @@ public class WaypointDialogHelper {
if(ctx.getDashboard().isVisible()) {
ctx.getDashboard().hideDashboard();
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
if (locationPoint instanceof FavouritePoint) {
ctx.getMapLayers().getContextMenuLayer()
.showContextMenuForSelectedObjects(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()));
} else {
// if (locationPoint instanceof FavouritePoint) {
// ctx.getMapLayers().getContextMenuLayer()
// .showContextMenuForSelectedObjects(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()));
// } else {
ctx.getMapLayers()
.getContextMenuLayer()
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
PointDescription.getSimpleName(locationPoint, ctx));
}
// }
}
}
}

View file

@ -95,6 +95,10 @@ public class MapContextMenu {
if (needStreetName()) {
acquireStreetName(new LatLon(pointDescription.getLat(), pointDescription.getLon()));
}
if (menuController != null) {
menuController.addPlainMenuItems(typeStr, this.pointDescription);
}
return true;
}
@ -130,17 +134,8 @@ public class MapContextMenu {
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(app, mapActivity, (Amenity)object);
if (!Algorithms.isEmpty(typeStr)) {
menuController.addPlainMenuItem(R.drawable.ic_action_info_dark, typeStr);
}
if (pointDescription != null) {
menuController.addPlainMenuItem(R.drawable.map_my_location, pointDescription.getLocationName(mapActivity, true).replaceAll("\n", ""));
}
} else if (object instanceof FavouritePoint) {
menuController = new FavouritePointMenuController(app, mapActivity, (FavouritePoint)object);
if (pointDescription != null) {
menuController.addPlainMenuItem(R.drawable.map_my_location, pointDescription.getLocationName(mapActivity, true).replaceAll("\n", ""));
}
}
}
}

View file

@ -1,11 +1,14 @@
package net.osmand.plus.mapcontextmenu.details;
import android.os.Bundle;
import android.util.Log;
import net.osmand.data.Amenity;
import net.osmand.data.PointDescription;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms;
@ -70,6 +73,16 @@ public class AmenityMenuController extends MenuController {
return typeStr;
}
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
if (!Algorithms.isEmpty(typeStr)) {
addPlainMenuItem(R.drawable.ic_action_info_dark, typeStr);
}
if (pointDescription != null) {
addPlainMenuItem(R.drawable.map_my_location, pointDescription.getLocationName(getMapActivity(), true).replaceAll("\n", ""));
}
}
@Override
public String getNameStr() {
return amenity.getName(getMapActivity().getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get());

View file

@ -5,6 +5,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import net.osmand.data.FavouritePoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -73,6 +74,13 @@ public class FavouritePointMenuController extends MenuController {
return fav.getName();
}
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
if (pointDescription != null) {
addPlainMenuItem(R.drawable.map_my_location, pointDescription.getLocationName(getMapActivity(), true).replaceAll("\n", ""));
}
}
@Override
public void saveEntityState(Bundle bundle, String key) {
bundle.putSerializable(key, fav);

View file

@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -43,6 +44,9 @@ public abstract class MenuController {
builder.addPlainMenuItem(iconId, text);
}
public void addPlainMenuItems(String typeStr, PointDescription pointDescription) {
}
public int getInitialMenuState() {
if (isLandscapeLayout()) {
return MenuState.FULL_SCREEN;