Search in sources :

Example 21 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class MapRouteInfoMenu method updateViaView.

private void updateViaView() {
    View mainView = getMainView();
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null || mainView == null) {
        return;
    }
    OsmandApplication app = mapActivity.getMyApplication();
    View viaLayout = mainView.findViewById(R.id.ViaLayout);
    String viaDescription = generateViaDescription();
    GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
    if (routeParams == null && Algorithms.isEmpty(viaDescription)) {
        AndroidUiHelper.updateVisibility(viaLayout, false);
        return;
    } else {
        AndroidUiHelper.updateVisibility(viaLayout, true);
    }
    if (routeParams != null) {
        viaLayout.setOnClickListener(v -> {
            MapActivity mapActivity1 = getMapActivity();
            if (mapActivity1 != null) {
                GPXRouteParamsBuilder routeParams1 = mapActivity1.getRoutingHelper().getCurrentGPXRoute();
                if (routeParams1 != null) {
                    hide();
                    selectTrack();
                }
            }
        });
    } else {
        viaLayout.setClickable(false);
        viaLayout.setOnClickListener(null);
    }
    setupViaText(mainView);
    FrameLayout viaButton = mainView.findViewById(R.id.via_button);
    AndroidUiHelper.updateVisibility(viaButton, routeParams == null || isFinishPointFromTrack());
    viaButton.setOnClickListener(v -> {
        MapActivity mapActivity12 = getMapActivity();
        if (mapActivity12 != null) {
            GPXRouteParamsBuilder routeParams12 = mapActivity12.getRoutingHelper().getCurrentGPXRoute();
            if (routeParams12 != null) {
                AddPointBottomSheetDialog.showInstance(mapActivity12, PointType.TARGET);
            } else if (mapActivity12.getMyApplication().getTargetPointsHelper().checkPointToNavigateShort()) {
                hide();
                WaypointsFragment.showInstance(mapActivity12.getSupportFragmentManager(), true);
            }
        }
    });
    LinearLayout viaButtonContainer = mainView.findViewById(R.id.via_button_container);
    setupButtonBackground(viaButton, viaButtonContainer);
    ImageView viaButtonImageView = mainView.findViewById(R.id.via_button_image_view);
    int iconId = routeParams != null ? R.drawable.ic_action_plus : R.drawable.ic_action_edit_dark;
    setupButtonIcon(viaButtonImageView, iconId);
    final View textView = mainView.findViewById(R.id.via_button_description);
    if (!editButtonCollapsing && !editButtonCollapsed && viaButton.getVisibility() == View.VISIBLE && textView.getVisibility() == View.VISIBLE) {
        editButtonCollapsing = true;
        collapseButtonAnimated(R.id.via_button, R.id.via_button_description, success -> {
            editButtonCollapsing = false;
            editButtonCollapsed = success;
        });
    } else if (editButtonCollapsed) {
        textView.setVisibility(View.GONE);
    }
    updateViaIcon(mainView);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) FavouritePoint(net.osmand.data.FavouritePoint) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) MapActivity(net.osmand.plus.activities.MapActivity)

Example 22 with GPXRouteParamsBuilder

use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.

the class MapRouteInfoMenu method updateViaIcon.

private void updateViaIcon(View parentView) {
    ImageView viaIcon = parentView.findViewById(R.id.viaIcon);
    OsmandApplication app = (OsmandApplication) parentView.getContext().getApplicationContext();
    GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
    if (routeParams != null) {
        viaIcon.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_polygom_dark));
    } else {
        viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) ImageView(android.widget.ImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView)

Aggregations

GPXRouteParamsBuilder (net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder)22 OsmandApplication (net.osmand.plus.OsmandApplication)10 File (java.io.File)8 ImageView (android.widget.ImageView)7 TextView (android.widget.TextView)7 MapActivity (net.osmand.plus.activities.MapActivity)7 View (android.view.View)6 GPXFile (net.osmand.GPXUtilities.GPXFile)6 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)6 Location (net.osmand.Location)5 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)4 LinearLayout (android.widget.LinearLayout)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 LatLon (net.osmand.data.LatLon)3 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 FrameLayout (android.widget.FrameLayout)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 ArrayList (java.util.ArrayList)2