Example #1
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Theme.Apply();

            //
            // Create the service
            //

            // Local CSV file
            service = MemoryDirectoryService.FromCsv("Data/XamarinDirectory.csv");

            // LDAP service - uncomment to try it out.
            //service = new LdapDirectoryService {
            //	Host = "ldap.mit.edu",
            //	SearchBase = "dc=mit,dc=edu",
            //};

            //
            // Load the favorites
            //
            var favoritesRepository = XmlFavoritesRepository.OpenIsolatedStorage("Favorites.xml");

            if (favoritesRepository.GetAll().Count() == 0)
            {
                favoritesRepository = XmlFavoritesRepository.OpenFile("Data/XamarinFavorites.xml");
                favoritesRepository.IsolatedStorageName = "Favorites.xml";
            }

            //
            // Load the last search
            //
            Search search = null;

            try {
                search = Search.Open("Search.xml");
            }
            catch (Exception) {
                search = new Search("Search.xml");
            }

            //
            // Build the UI
            //
            favoritesViewController = new FavoritesViewController(favoritesRepository, service, search);

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = new UINavigationController(favoritesViewController);
            window.MakeKeyAndVisible();

            //
            // Show the login screen at startup
            //
            var login = new LoginViewController(service);

            favoritesViewController.PresentViewController(login, false, null);

            return(true);
        }
Example #2
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();

            if (LoginViewModel.ShouldShowLogin(App.LastUseTime))
            {
                await Navigation.PushModalAsync(new LoginView());
            }

            favoritesRepository = await XmlFavoritesRepository.OpenIsolatedStorage("XamarinFavorites.xml");

            if (favoritesRepository.GetAll().Count() == 0)
            {
                favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml");
            }

            viewModel            = new FavoritesViewModel(favoritesRepository, true);
            listView.ItemsSource = viewModel.Groups;
        }