Пример #1
0
        async void HandleAuthenticatedEvent()
        {
            // set again
            if (URL.ServerURL != null && !URL.ServerURL.Contains(StringRef.DemoURL))
            {
                this.NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] {
                    settingButton          = new UIBarButtonItem(UIImage.FromBundle("Assets/Buttons/setting.png"), UIBarButtonItemStyle.Plain, HandleSettingButtonTouchUpInside),
                    searchButton           = new UIBarButtonItem(UIBarButtonSystemItem.Search, HandleSearchButtonTouchUpInside),
                    contentSyncErrorButton = new UIBarButtonItem(contentSyncButton)
                }, true);
            }
            else
            {
                this.NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] {
                    settingButton = new UIBarButtonItem(UIImage.FromBundle("Assets/Buttons/setting.png"), UIBarButtonItemStyle.Plain, HandleSettingButtonTouchUpInside),
                    searchButton  = new UIBarButtonItem(UIBarButtonSystemItem.Search, HandleSearchButtonTouchUpInside),
                }, true);
            }

            // Check books to download
            BookUpdater.CheckBooks2Download();

            // Start the check for update timer
            BookUpdateTimer.Start();

            // Start syncing if necessary
            if (Settings.SyncOn)
            {
                await OpenSyncView();
            }
        }
        private void UpdateCollectionView(LibraryBookView bookView)
        {
            if (dataSource != null && dataSource.BookList != null && dataSource.BookList.Count > 0)
            {
                try
                {
                    bookView.RemoveFromSuperview();

                    Book book = bookView.LibraryBook.Copy();
                    book.Status = Book.BookStatus.PENDING2DOWNLOAD;

                    // Add the book to the device
                    BooksOnDeviceAccessor.AddBook(book);

                    // Start the download
                    BookUpdater.CheckBooks2Download();

                    // Update available badge
                    UpdateAvailableBadge();

                    // Remove from the list
                    List <Book> newBookList = new List <Book>(dataSource.BookList);
                    int         removeIdx   = dataSource.GetBookIndex(book.ID);
                    newBookList.RemoveAt(removeIdx);

                    collectionView.PerformBatchUpdates(delegate
                    {
                        foreach (Book b in dataSource.BookList)
                        {
                            if (b.ID != book.ID)
                            {
                                NSIndexPath fromIndexPath = dataSource.GetIndexPath(b.ID);
                                int toRow = newBookList.IndexOf(b);
                                if (fromIndexPath != null && fromIndexPath.Row >= 0 && toRow >= 0)
                                {
                                    NSIndexPath toIndexPath = NSIndexPath.FromRowSection(toRow, 0);
                                    collectionView.MoveItem(fromIndexPath, toIndexPath);
                                }
                            }
                        }
                    }, delegate
                    {
                        downloadAnimation = false;

                        RefreshTable();
                    });
                }
                catch (Exception ex)
                {
                    Logger.WriteLineDebugging("LibraryViewController - UpdateCollectionView: {0}", ex.ToString());
                }
            }
        }
        async private Task OpenSyncView()
        {
            LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false);

            // Start Push and Pull
            if (!CloudSync.SyncingInProgress)
            {
                CloudSync.SyncingInProgress = true;
                await eBriefingService.Run(() => CloudSync.PushAndPull());

                CloudSync.SyncingInProgress = false;
            }

            LoadingView.Hide();

            // Once syncing is finished, check books to download
            BookUpdater.CheckBooks2Download();
        }
Пример #4
0
        async private Task OpenSyncView(bool bfromSyncButton = false)
        {
            LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false);

            // Start Push and Pull
            if (!CloudSync.SyncingInProgress)
            {
                CloudSync.SyncingInProgress = true;
                await eBriefingService.Run(() => CloudSync.PushAndPull());

                CloudSync.SyncingInProgress = false;
            }

            LoadingView.Hide();

            // Once syncing is finished, check books to download
            BookUpdater.CheckBooks2Download();

            // Refresh
            HandleRefreshEvent1(this, EventArgs.Empty);

            if (tabBarController.SelectedIndex == 1)
            {
                HandleRefreshEvent2(this, EventArgs.Empty);
            }
            else if (tabBarController.SelectedIndex == 2)
            {
                HandleRefreshEvent3(this, EventArgs.Empty);
            }
            else if (tabBarController.SelectedIndex == 3)
            {
                vc4.LoadBooks();
            }

            if (!bfromSyncButton)
            {
                // Start the PUSH timer in the background
                SyncPushTimer.Start();
            }
        }