コード例 #1
0
        private void PopulateRoute(String routeID, String subRouteUID)
        {
            IEnumerable <StopOfRoute> stopsOfSingleRoute = StopOfRoute.RetrieveFromJson(string.Format(URL_STOP_OF_ROUTE, routeID))
                                                           .Where(entity => string.Equals(entity.SubRouteUID, subRouteUID));

            if (stopsOfSingleRoute.Count() == 0)
            {
                return;
            }

            IEnumerable <RoutePrediction> predictions = RoutePrediction.RetrieveFromJson(string.Format(URL_ESTIMATED_ARRIVAL, routeID, subRouteUID));
            StopArrivalPrediction         view        = new StopArrivalPrediction(stopsOfSingleRoute.First(), predictions);

            Content = new ScrollView {
                Content = view
            };
        }
コード例 #2
0
        private void PopulateArriveRoute(String stopID, String stopName)
        {
            PageLayout.Children.Add(new Label {
                Text = "即將到達路線"
            });
            IEnumerable <StopOnRoute> StopsOnSingleRoute = StopOnRouteSQLiteRepository.Instance.Retrieve(stopID);

            List <string> processedRouteUID = new List <string>();
            List <string> processedRouteID  = new List <string>();

            foreach (StopOnRoute StopOnSingleRoute in StopsOnSingleRoute)
            {
                IEnumerable <RoutePrediction> arriveRoutes = RoutePrediction.RetrieveFromJson(string.Format("http://ptx.transportdata.tw/MOTC/v2/Bus/EstimatedTimeOfArrival/InterCity?$filter=SubRouteUID%20eq%20%27{0}%27%20and%20StopName/Zh_tw%20eq%20%27{1}%27&$top=30&$format=JSON", StopOnSingleRoute.SubRouteUID, stopName));
                foreach (RoutePrediction arriveRoute in arriveRoutes)
                {
                    if (arriveRoute.PlateNumb != "-1")
                    {
                        Button routeDetails = CreateRouteArriveButton(arriveRoute, processedRouteUID, processedRouteID);
                        CheckArriveRoute = true;
                        if (routeDetails == null)
                        {
                            continue;
                        }
                        processedRouteUID.Add(arriveRoute.SubRouteUID);
                        PageLayout.Children.Add(routeDetails);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (!CheckArriveRoute)
            {
                PageLayout.Children.Add(new Label {
                    Text = "本站無即將到達路線", FontSize = 20, TextColor = Color.Red, HorizontalOptions = LayoutOptions.CenterAndExpand
                });
            }
        }