public MasterNavigator(ViewManager viewManager, FacebookService facebookService, ViewPage startupPage) { Verify.IsNotNull(viewManager, "viewManager"); Verify.IsNotNull(facebookService, "facebookService"); _viewManager = viewManager; HomeNavigator = new HomePage().GetNavigator(null, facebookService.Dispatcher); PhotoAlbumsNavigator = new PhotoAlbumCollectionNavigator(facebookService.PhotoAlbums, FacebookObjectId.Create("Photo Albums"), null); FriendsNavigator = new ContactCollectionNavigator(facebookService.Friends, FacebookObjectId.Create("Friends"), null); ProfileNavigator = new ContactNavigator(facebookService.MeContact, FacebookObjectId.Create("Me"), null); _children = new[] { HomeNavigator, PhotoAlbumsNavigator, FriendsNavigator, ProfileNavigator }; Navigator startupNavigator = null; switch (startupPage) { case ViewPage.Friends: startupNavigator = FriendsNavigator; _startupCollection = facebookService.Friends; break; case ViewPage.Newsfeed: startupNavigator = HomeNavigator; _startupCollection = facebookService.NewsFeed; break; case ViewPage.Photos: startupNavigator = PhotoAlbumsNavigator; _startupCollection = facebookService.PhotoAlbums; break; case ViewPage.Profile: startupNavigator = ProfileNavigator; _startupCollection = null; break; } _loadingPage = new LoadingPage(startupNavigator); if (_startupCollection != null) { _startupCollection.CollectionChanged += _SignalNewsfeedChanged; } else { _loadingPage.Signal(); } _loginPage = new LoginPage(facebookService.ApplicationId, facebookService.ApplicationKey, _loadingPage.GetNavigator()); LoginPageNavigator = _loginPage.Navigator; }
private void _SignalNewsfeedChanged(object sender, NotifyCollectionChangedEventArgs e) { _startupCollection.CollectionChanged -= _SignalNewsfeedChanged; _loadingPage.Signal(); }