Search in sources :

Example 1 with MapRouteInfoMenu

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();
}
Also used : LatLon(net.osmand.data.LatLon) MapRouteInfoMenu(net.osmand.plus.routepreparationmenu.MapRouteInfoMenu) OsmandApplication(net.osmand.plus.OsmandApplication) FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) Fragment(androidx.fragment.app.Fragment) MenuBottomSheetDialogFragment(net.osmand.plus.base.MenuBottomSheetDialogFragment)

Example 2 with MapRouteInfoMenu

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;
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) MapRouteInfoMenu(net.osmand.plus.routepreparationmenu.MapRouteInfoMenu)

Example 3 with MapRouteInfoMenu

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;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Bundle(android.os.Bundle) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) Drawable(android.graphics.drawable.Drawable) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) MapRouteInfoMenu(net.osmand.plus.routepreparationmenu.MapRouteInfoMenu) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) MapActivity(net.osmand.plus.activities.MapActivity) Nullable(androidx.annotation.Nullable)

Aggregations

MapRouteInfoMenu (net.osmand.plus.routepreparationmenu.MapRouteInfoMenu)3 LatLon (net.osmand.data.LatLon)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageButton (android.widget.ImageButton)1 ListView (android.widget.ListView)1 Nullable (androidx.annotation.Nullable)1 Fragment (androidx.fragment.app.Fragment)1 FragmentManager (androidx.fragment.app.FragmentManager)1 MapActivity (net.osmand.plus.activities.MapActivity)1 MapViewTrackingUtilities (net.osmand.plus.base.MapViewTrackingUtilities)1 MenuBottomSheetDialogFragment (net.osmand.plus.base.MenuBottomSheetDialogFragment)1 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)1 FavouritesHelper (net.osmand.plus.myplaces.FavouritesHelper)1