public static List getNavigateHome()

in car_app_library/navigation/common/src/main/java/androidx/car/app/sample/navigation/common/model/DemoScripts.java [131:349]


    public static List<Instruction> getNavigateHome(@NonNull CarContext carContext) {
        ArrayList<Instruction> instructions = new ArrayList<>();

        DateTimeWithZone arrivalTimeAtDestination = getCurrentDateTimeZoneWithOffset(30);

        CarIcon lanesImage =
                new CarIcon.Builder(IconCompat.createWithResource(carContext, R.drawable.lanes))
                        .build();
        CarIcon junctionImage =
                new CarIcon.Builder(
                        IconCompat.createWithResource(
                                carContext,
                                R.drawable.junction_image))
                        .build();

        Lane straightNormal =
                new Lane.Builder()
                        .addDirection(LaneDirection.create(SHAPE_STRAIGHT, false))
                        .build();
        Lane rightHighlighted =
                new Lane.Builder()
                        .addDirection(LaneDirection.create(SHAPE_NORMAL_RIGHT, true))
                        .build();

        int step1IconResourceId =
                getTurnIconResourceId(Maneuver.TYPE_ROUNDABOUT_ENTER_AND_EXIT_CCW_WITH_ANGLE);
        Step step1 =
                new Step.Builder("State Street")
                        .setManeuver(
                                getManeuverWithExitNumberAndAngle(
                                        carContext,
                                        Maneuver.TYPE_ROUNDABOUT_ENTER_AND_EXIT_CCW_WITH_ANGLE,
                                        step1IconResourceId,
                                        2,
                                        270))
                        .setRoad("State Street")
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(rightHighlighted)
                        .setLanesImage(lanesImage)
                        .build();
        int step2IconResourceId = getTurnIconResourceId(Maneuver.TYPE_TURN_NORMAL_LEFT);
        Step step2 =
                new Step.Builder("Kirkland Way")
                        .setManeuver(
                                getManeuver(
                                        carContext,
                                        Maneuver.TYPE_TURN_NORMAL_LEFT,
                                        step2IconResourceId))
                        .setRoad("Kirkland Way")
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(rightHighlighted)
                        .setLanesImage(lanesImage)
                        .build();
        int step3IconResourceId = getTurnIconResourceId(Maneuver.TYPE_TURN_NORMAL_RIGHT);
        Step step3 =
                new Step.Builder("6th Street.")
                        .setManeuver(
                                getManeuver(
                                        carContext,
                                        Maneuver.TYPE_TURN_NORMAL_RIGHT,
                                        step3IconResourceId))
                        .setRoad("6th Street.")
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(straightNormal)
                        .addLane(rightHighlighted)
                        .setLanesImage(lanesImage)
                        .build();
        int step4IconResourceId = getTurnIconResourceId(Maneuver.TYPE_DESTINATION_RIGHT);
        Step step4 =
                new Step.Builder("Google Kirkland.")
                        .setManeuver(
                                getManeuver(
                                        carContext, TYPE_DESTINATION_RIGHT, step4IconResourceId))
                        .setRoad("Google Kirkland.")
                        .build();

        // Start the navigation and add destination and steps.
        instructions.add(
                Instruction.builder(Instruction.Type.START_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .build());

        Destination destination =
                new Destination.Builder().setName("Work").setAddress("747 6th St.").build();
        instructions.add(
                Instruction.builder(
                        Instruction.Type.ADD_DESTINATION_NAVIGATION,
                        INSTRUCTION_NO_ELAPSED_TIME)
                        .setDestination(destination)
                        .build());

        instructions.add(
                Instruction.builder(Instruction.Type.SET_REROUTING, TimeUnit.SECONDS.toMillis(5))
                        .setDestinationTravelEstimate(
                                new TravelEstimate.Builder(
                                        Distance.create(350, Distance.UNIT_METERS),
                                        arrivalTimeAtDestination)
                                        .setRemainingTimeSeconds(
                                                /* remainingTimeSeconds= */ DISTANCE_METERS
                                                        / SPEED_METERS_PER_SEC)
                                        .build())
                        .setNotification(
                                true,
                                carContext.getString(R.string.navigation_rerouting),
                                null,
                                R.drawable.ic_launcher)
                        .build());

        instructions.add(
                Instruction.builder(
                        Instruction.Type.ADD_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .setStep(step1)
                        .build());
        instructions.add(
                Instruction.builder(
                        Instruction.Type.ADD_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .setStep(step2)
                        .build());
        instructions.add(
                Instruction.builder(
                        Instruction.Type.ADD_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .setStep(step3)
                        .build());
        instructions.add(
                Instruction.builder(
                        Instruction.Type.ADD_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .setStep(step4)
                        .build());

        // Add trip positions for each step.
        int updateDistanceRemaining = DISTANCE_METERS;
        instructions.addAll(
                generateTripUpdateSequence(
                        /* count= */ 4,
                        /* startDestinationDistanceRemaining= */ updateDistanceRemaining,
                        /* startStepDistanceRemaining= */ 100,
                        arrivalTimeAtDestination,
                        "3rd Street",
                        junctionImage,
                        /* showLanes= */ true,
                        "onto State Street",
                        SPEED_METERS_PER_SEC,
                        step1IconResourceId));
        instructions.add(
                Instruction.builder(
                        Instruction.Type.POP_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .build());
        updateDistanceRemaining -= 100;

        instructions.addAll(
                generateTripUpdateSequence(
                        /* count= */ 6,
                        /* startDestinationDistanceRemaining= */ updateDistanceRemaining,
                        /* startStepDistanceRemaining= */ 150,
                        arrivalTimeAtDestination,
                        "State Street",
                        junctionImage,
                        /* showLanes= */ true,
                        "onto Kirkland Way",
                        SPEED_METERS_PER_SEC,
                        step2IconResourceId));
        instructions.add(
                Instruction.builder(
                        Instruction.Type.POP_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .build());
        updateDistanceRemaining -= 150;

        instructions.addAll(
                generateTripUpdateSequence(
                        /* count= */ 4,
                        /* startDestinationDistanceRemaining= */ updateDistanceRemaining,
                        /* startStepDistanceRemaining= */ 100,
                        arrivalTimeAtDestination,
                        "Kirkland Way",
                        junctionImage,
                        /* showLanes= */ true,
                        "onto 6th Street",
                        SPEED_METERS_PER_SEC,
                        step3IconResourceId));
        instructions.add(
                Instruction.builder(
                        Instruction.Type.POP_STEP_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .build());
        updateDistanceRemaining -= 100;

        instructions.addAll(
                generateTripUpdateSequence(
                        /* count= */ 4,
                        /* startDestinationDistanceRemaining= */ updateDistanceRemaining,
                        /* startStepDistanceRemaining= */ 100,
                        arrivalTimeAtDestination,
                        "6th Street",
                        /* junctionImage= */ null,
                        /* showLanes= */ false,
                        "to Google Kirkland on right",
                        SPEED_METERS_PER_SEC,
                        step4IconResourceId));

        // Set arrived state and then stop navigation.
        instructions.add(
                Instruction.builder(Instruction.Type.SET_ARRIVED, TimeUnit.SECONDS.toMillis(5))
                        .build());

        instructions.add(
                Instruction.builder(Instruction.Type.POP_DESTINATION_NAVIGATION,
                        INSTRUCTION_NO_ELAPSED_TIME)
                        .build());
        instructions.add(
                Instruction.builder(Instruction.Type.END_NAVIGATION, INSTRUCTION_NO_ELAPSED_TIME)
                        .build());
        return instructions;
    }