use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapMultiSelectionMenu method createCollection.
private void createCollection(Map<Object, IContextMenuProvider> selectedObjects) {
this.selectedObjects.clear();
this.selectedObjects.putAll(selectedObjects);
objects.clear();
for (Map.Entry<Object, IContextMenuProvider> e : selectedObjects.entrySet()) {
Object selectedObj = e.getKey();
IContextMenuProvider contextObject = selectedObjects.get(selectedObj);
LatLon ll = null;
PointDescription pointDescription = null;
if (contextObject != null) {
ll = contextObject.getObjectLocation(selectedObj);
pointDescription = contextObject.getObjectName(selectedObj);
}
if (ll == null) {
ll = latLon;
}
if (pointDescription == null) {
pointDescription = new PointDescription(latLon.getLatitude(), latLon.getLongitude());
}
MenuObject menuObject = new MenuObject(ll, pointDescription, selectedObj, getMapActivity());
objects.add(menuObject);
if (contextObject instanceof ContextMenuLayer.IContextMenuProviderSelection) {
menuObject.order = ((ContextMenuLayer.IContextMenuProviderSelection) contextObject).getOrder(selectedObj);
}
}
Collections.sort(objects, new Comparator<MenuObject>() {
@Override
public int compare(MenuObject obj1, MenuObject obj2) {
if (obj1.order == obj2.order) {
return obj1.getTitleStr().compareToIgnoreCase(obj2.getTitleStr());
} else {
return obj1.order - obj2.order;
}
}
});
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapRouteInfoMenu method generateViaDescription.
public String generateViaDescription() {
TargetPointsHelper targets = getTargets();
List<TargetPoint> points = targets.getIntermediatePointsNavigation();
if (points.size() == 0) {
return "";
}
StringBuilder via = new StringBuilder();
for (int i = 0; i < points.size(); i++) {
if (i > 0) {
via.append(" ");
}
TargetPoint p = points.get(i);
String description = p.getOnlyName();
via.append(getRoutePointDescription(p.point, description));
boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity) && !intermediateRequestsLatLon.contains(p.point);
if (needAddress) {
AddressLookupRequest lookupRequest = new AddressLookupRequest(p.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
updateMenu();
}
}, null);
intermediateRequestsLatLon.add(p.point);
geocodingLookupService.lookupAddress(lookupRequest);
}
}
return via.toString();
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class MapRouteInfoMenu method updateViaView.
private void updateViaView(final View parentView) {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
viaLayoutDivider.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.VISIBLE);
} else {
swapDirectionView.setVisibility(View.GONE);
viaLayout.setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
}
viaLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getTargets().checkPointToNavigateShort()) {
mapActivity.getMapActions().openIntermediatePointsDialog();
}
}
});
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points, isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
swapDirectionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
TargetPointsHelper targetPointsHelper = getTargets();
TargetPoint startPoint = targetPointsHelper.getPointToStart();
TargetPoint endPoint = targetPointsHelper.getPointToNavigate();
if (startPoint == null) {
Location loc = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
if (loc != null) {
startPoint = TargetPoint.createStartPoint(new LatLon(loc.getLatitude(), loc.getLongitude()), new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location)));
}
}
if (startPoint != null && endPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);
updateFromIcon();
updateToIcon(parentView);
}
}
});
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class FavouritePointMenuBuilder method getCollapsableFavouritesView.
private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
List<FavouritePoint> points = group.points;
for (int i = 0; i < points.size() && i < 10; i++) {
final FavouritePoint point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
String name = point.getName();
button.setText(name);
if (!selected) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
mapActivity.getContextMenu().show(latLon, pointDescription, point);
}
});
}
view.addView(button);
}
if (points.size() > 10) {
TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
use of net.osmand.data.PointDescription in project Osmand by osmandapp.
the class TransportRouteController method showTransportStop.
private void showTransportStop(TransportStop stop) {
if (mapContextMenu != null) {
transportRoute.stop = stop;
transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, transportRoute.getDescription(getMapActivity().getMyApplication(), false));
updateControllers();
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);
}
}
Aggregations