use of net.osmand.plus.routepreparationmenu.MapRouteInfoMenu in project Osmand by osmandapp.
the class FavouritesBottomSheetMenuFragment method selectFavorite.
private void selectFavorite(FavouritePoint point) {
OsmandApplication app = getMyApplication();
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
FavouritesHelper favorites = app.getFavoritesHelper();
LatLon ll = new LatLon(point.getLatitude(), point.getLongitude());
switch(pointType) {
case START:
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription(app));
break;
case TARGET:
if (getActivity() != null) {
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(getActivity());
}
break;
case INTERMEDIATE:
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), point.getPointDescription(app));
break;
case HOME:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.HOME, null);
break;
case WORK:
favorites.setSpecialPoint(ll, FavouritePoint.SpecialPointType.WORK, null);
break;
}
MapRouteInfoMenu routeMenu = getMapRouteInfoMenu();
if (routeMenu != null) {
setupMapRouteInfoMenuSpinners(routeMenu);
updateMapRouteInfoMenuFromIcon(routeMenu);
}
Fragment fragment = getTargetFragment();
if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), 0, null);
}
dismiss();
}
use of net.osmand.plus.routepreparationmenu.MapRouteInfoMenu in project Osmand by osmandapp.
the class RouteLineAppearanceFragment method showInstance.
public static boolean showInstance(@NonNull MapActivity mapActivity, @Nullable ApplicationMode appMode) {
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
if (AndroidUtils.isFragmentCanBeAdded(fragmentManager, TAG)) {
MapRouteInfoMenu mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu();
if (mapRouteInfoMenu.isVisible()) {
mapRouteInfoMenu.hide();
}
RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment();
fragment.appMode = appMode;
fragmentManager.beginTransaction().replace(R.id.fragmentContainer, fragment, TAG).addToBackStack(TAG).commitAllowingStateLoss();
return true;
}
return false;
}
use of net.osmand.plus.routepreparationmenu.MapRouteInfoMenu in project Osmand by osmandapp.
the class MapMarkerSelectionFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle bundle = null;
if (getArguments() != null) {
bundle = getArguments();
} else if (savedInstanceState != null) {
bundle = savedInstanceState;
}
if (bundle != null) {
pointType = PointType.valueOf(bundle.getString(POINT_TYPE_KEY));
}
MapActivity mapActivity = getMapActivity();
OsmandApplication app = getMyApplication();
if (mapActivity != null) {
MapRouteInfoMenu routeInfoMenu = mapActivity.getMapRouteInfoMenu();
onClickListener = routeInfoMenu.getOnMarkerSelectListener();
screenOrientation = app.getUIUtilities().getScreenOrientation();
MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
if (trackingUtils != null) {
Float head = trackingUtils.getHeading();
float mapRotation = mapActivity.getMapRotate();
LatLon mw = mapActivity.getMapLocation();
boolean mapLinked = trackingUtils.isMapLinkedToLocation();
useCenter = !mapLinked;
loc = mw;
if (useCenter) {
heading = -mapRotation;
} else {
heading = head;
}
}
}
nightMode = !app.getSettings().isLightContent();
View view = inflater.inflate(R.layout.map_marker_selection_fragment, container, false);
ImageButton closeButton = (ImageButton) view.findViewById(R.id.closeButton);
Drawable icBack = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app));
closeButton.setImageDrawable(icBack);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
ListView listView = (ListView) view.findViewById(android.R.id.list);
final ArrayAdapter<MapMarker> adapter = new MapMarkersListAdapter();
List<MapMarker> markers = getMyApplication().getMapMarkersHelper().getMapMarkers();
if (markers.size() > 0) {
for (MapMarker marker : markers) {
adapter.add(marker);
}
}
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (onClickListener != null) {
onClickListener.onSelect(position, pointType);
}
dismiss();
}
});
return view;
}
Aggregations