Beispiel #1
0
        private void bindStartSelectButtonDelegates(Button start, Button select,
                                                    AutoCompleteTextView originBox, AutoCompleteTextView destinationBox)
        {
            select.Click += async delegate
            {
                //Gets the coordinates for the origin and destination points
                double[] originCoords      = mbi.ConvertAddressToGpsCoordinates(originBox.Text, map.MyLocation.Latitude, map.MyLocation.Longitude);
                double[] destinationCoords = mbi.ConvertAddressToGpsCoordinates(destinationBox.Text, map.MyLocation.Latitude, map.MyLocation.Longitude)
                ;
                //Clears old routes
                Tools.clearRoutes(map);

                //Asks Otp for response based on the origin and destination
                otpResponse = await OtpAPI.Query(originCoords, destinationCoords);

                //Plots the first two routes in the response
                Tools.plotRoute(otpResponse, map, 2, colors);

                //Sets the camera to show the overall route
                Tools.setRoutingCamera(originCoords, destinationCoords, map);

                //Parses the itinerary, uses it to create an adapter for a recycler view
                Itinerary itin    = OtpAPI.ParseItinerary(otpResponse["plan"]["itineraries"][0]);
                var       adapter = new RouteSummaryRowAdapter(itin);

                //Binds the adapter to the recyclerView
                var rv = FindViewById <RecyclerView>(Resource.Id.slidingRecycler);
                rv.SetAdapter(adapter);

                //Sets the start button to be fully opaque and clickable
                start.Alpha     = 1;
                start.Clickable = true;

                //Slides up the bottom panel to show the route summary
                FindViewById <SlidingUpPanelLayout>(Resource.Id.sliding_layout).SetPanelState(SlidingUpPanelLayout.PanelState.Expanded);
            };
            start.Click += delegate {
                //Reconfigures the ui for the navigation mode, now that the user wants to start navigation
                reconfigureUiForNavigation(0);
            };
        }
Beispiel #2
0
        /**Turn By Turn Navigation Ui**/

        private void reconfigureUiForNavigation(int itineraryIndex)
        {
            //Disable the actv layout, and route/start buttons
            FindViewById <LinearLayout>(Resource.Id.actvLayout).Visibility = ViewStates.Gone;
            FindViewById <Button>(Resource.Id.startButton).Visibility      = ViewStates.Gone;
            FindViewById <Button>(Resource.Id.routeButton).Visibility      = ViewStates.Gone;

            //Binds a variable to the recyclerView
            RecyclerView recyclerView = FindViewById <RecyclerView>(Resource.Id.slidingRecycler);

            //Parses the itinerary selected
            Itinerary itin = OtpAPI.ParseItinerary(otpResponse["plan"]["itineraries"][itineraryIndex]);

            //Binds a variable to a configured recycler view
            recyclerView = Tools.configureRecyclerViewForNavigation(itin, recyclerView);

            //Sets up the turn by turn ui (the upper section)
            initializeUpperNavigationUi(itin, recyclerView);

            //Sets the first row in the recyclerView to be highlighted
            ((StepRowAdapter)recyclerView.GetAdapter()).HighlightedRow = 0;

            //Hides the recentering button when navigating
            Tools.toggleVisibility(FindViewById <FloatingActionButton>(Resource.Id.recenterOnUserActionButton));

            //Binds the backToRoutingButton to go back to the routing screen
            Button backToRoutingButton = FindViewById <Button>(Resource.Id.backToRoutingButton);

            backToRoutingButton.Click += delegate
            {
                //TODO: implement reverse screen reconfiguration
                reconfigureUiForRouting();
            };

            //Configures the station image thumbnail with the sample image
            configureStationImage();

            //Starts turn by turn tracking for stepping through the steps
            initializeTurnByTurnTracking(itin, recyclerView);
        }