Esempio n. 1
0
        void HandleUpdateAvailableBadgeEvent(object sender, EventArgs e)
        {
            try
            {
                List <Book> sBooks = BooksOnServerAccessor.GetBooks();
                List <Book> dBooks = BooksOnDeviceAccessor.GetBooks();

                int count = 0;
                if (sBooks != null && dBooks != null)
                {
                    HashSet <String> dIDs = new HashSet <String>(dBooks.Select(d => d.ID));
                    var results           = sBooks.Where(s => !dIDs.Contains(s.ID)).Where(s => !s.Viewed).ToList();
                    if (results != null)
                    {
                        count = results.Count;
                    }
                }
                else if (sBooks != null)
                {
                    count = sBooks.Where(s => !s.Viewed).ToList().Count;
                }

                UpdateBadge(3, count);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("eBriefingViewController - HandleUpdateAvailableBadgeEvent: {0}", ex.ToString());
            }
        }
            public BookSearchDisplayDelegate(PopoverSearchController parent)
            {
                this.parent = parent;

                myBooks        = BooksOnDeviceAccessor.GetBooks();
                availableBooks = BooksOnServerAccessor.GetBooks();
            }
        private void LoadCollectionView()
        {
            // Load collectionView
            if (collectionView != null)
            {
                List <Book> bookList = null;

                // Only show those books that are not on the device
                List <Book> sBooks = BooksOnServerAccessor.GetBooks();
                List <Book> dBooks = BooksOnDeviceAccessor.GetBooks();

                if (sBooks != null && dBooks != null)
                {
                    HashSet <String> dIDs = new HashSet <String>(dBooks.Select(d => d.ID));
                    var results           = sBooks.Where(s => !dIDs.Contains(s.ID)).ToList();
                    if (results != null)
                    {
                        bookList = results;
                    }
                }
                else if (sBooks != null)
                {
                    bookList = sBooks;
                }

                LoadingView.Hide();

                if (bookList == null || bookList.Count == 0)
                {
                    UpdateStatusLabel("There are no more available books.");

                    UpdateAvailableBadge();
                }
                else
                {
                    dataSource = new LibraryDataSource(new List <Book>(bookList), this);
                    dataSource.ItemPressedEvent += HandleItemPressedEvent;
                    dataSource.DownloadEvent    += HandleDownloadEvent;
                    collectionView.Source        = dataSource;
                    collectionView.ReloadData();

                    ShowHideStatusLabel(false);
                }
            }
        }
        public void RetrieveBooks()
        {
            if (!Reachability.IsDefaultNetworkAvailable())
            {
                UpdateStatusLabel(StringRef.connectionRequired);
            }
            else
            {
                List <Book> bookList = BooksOnServerAccessor.GetBooks();
                if (bookList == null)
                {
                    UpdateStatusLabel("There are no available books.");

                    Failed2RetrieveBooks();
                }
                else
                {
                    // Load collectionView
                    LoadCollectionView();
                }
            }
        }