Esempio n. 1
0
        void busServiceModel_StopsForRoute_Completed(object sender, EventArgs.StopsForRouteEventArgs e)
        {
            // If the main page is still loading we might receive callbacks for other
            // routes. This fix isn't perfect, but it should fix us in the vast majority
            // of the cases. It will only cause problems if we get two callsbacks for
            // one of the routes we're searching for.
            if (CurrentViewState.CurrentRoutes.Contains(e.route) == true)
            {
                lock (routeDirectionsLock)
                {
                    e.routeStops.ForEach(routeStop => pendingRouteDirections.Add(routeStop));

                    // Subtract 1 because we haven't decremented the count yet
                    if (pendingRouteDirectionsCount - 1 == 0)
                    {
                        if (LocationTracker.LocationKnown == true)
                        {
                            pendingRouteDirections.Sort(new RouteStopsDistanceComparer(locationTracker.CurrentLocation));
                        }

                        pendingRouteDirections.ForEach(route => UIAction(() => RouteDirections.Add(route)));
                    }
                }

                pendingRouteDirectionsCount--;
                operationTracker.DoneWithOperation("StopsForRoute_" + e.route.id);
            }
        }
        void busServiceModel_StopsForRoute_Completed(object sender, EventArgs.StopsForRouteEventArgs e)
        {
            e.routeStops.ForEach(r => UIAction(() =>
            {
                if (directionHelper.ContainsKey(e.route.id))
                {
                    directionHelper[e.route.id].Add(r);
                }
            }));

            operationTracker.DoneWithOperation(string.Format("StopsForRoute_{0}", e.route.id));
        }
Esempio n. 3
0
            public void busServiceModel_StopsForRoute_Completed(object sender, EventArgs.StopsForRouteEventArgs e)
            {
                Debug.Assert(e.error == null);

                if (e.error == null)
                {
                    viewModel.UIAction(() => viewModel.CurrentViewState.CurrentRouteDirection = null);

                    e.routeStops.ForEach(routeStop =>
                    {
                        // These aren't always the same, hopefully this comparison will work
                        if (routeStop.name.Contains(arrival.tripHeadsign) || arrival.tripHeadsign.Contains(routeStop.name))
                        {
                            viewModel.UIAction(() =>
                            {
                                viewModel.CurrentViewState.CurrentRouteDirection = routeStop;
                                viewModel.CurrentViewState.CurrentRoute          = routeStop.route;
                            });
                        }
                    }
                                         );

                    viewModel.UIAction(() =>
                    {
                        // This will happen if we don't find a match between the headsign and route direction
                        // The 48 route in particular has this problem, if we leave this as null the
                        // filtered appbar icon won't update correctly
                        if (viewModel.CurrentViewState.CurrentRouteDirection == null)
                        {
                            Debug.Assert(false);
                            viewModel.CurrentViewState.CurrentRouteDirection = new RouteStops();
                        }
                    }
                                       );

                    if (uiCallback != null)
                    {
                        // Make this callback from the UI thread, because that is the easiest way
                        // to ensure it happens after the above UI thread operations.  If this callback
                        // occurs before the ViewState is updated it will cause a bug
                        viewModel.UIAction(() => uiCallback.Invoke());
                    }
                }
                else
                {
                    viewModel.ErrorOccured(this, e.error);
                }

                viewModel.busServiceModel.StopsForRoute_Completed -= new EventHandler <EventArgs.StopsForRouteEventArgs>(this.busServiceModel_StopsForRoute_Completed);
                viewModel.operationTracker.DoneWithOperation("StopsForRoute");
            }
Esempio n. 4
0
        void busServiceModel_StopsForRoute_Completed(object sender, EventArgs.StopsForRouteEventArgs e)
        {
            Debug.Assert(e.error == null);

            if (e.error == null)
            {
                e.routeStops.ForEach(r => UIAction(() =>
                {
                    if (directionHelper.ContainsKey(e.route.id))
                    {
                        directionHelper[e.route.id].Add(r);
                    }
                }));
            }
            else
            {
                ErrorOccured(this, e.error);
            }

            operationTracker.DoneWithOperation(string.Format("StopsForRoute_{0}", e.route.id));
        }