Ejemplo n.º 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();
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            BookUpdater.RegisterASIDelegate(this);

            this.NavigationController.InteractivePopGestureRecognizer.Enabled = false;

            // Initialize controls
            InitializeControls();

            if (!String.Equals(URL.ServerURL, StringRef.DemoURL))
            {
                if (!String.IsNullOrEmpty(URL.ServerURL))
                {
                    urlField.Text = URL.ServerURL;
                }

                if (!String.IsNullOrEmpty(Settings.UserID))
                {
                    idField.Text = Settings.UserID;
                }

                String password = KeychainAccessor.Password;
                if (!String.IsNullOrEmpty(password))
                {
                    passwordField.Text = password;
                }

                if (!String.IsNullOrEmpty(Settings.Domain))
                {
                    domainField.Text = Settings.Domain;
                }
            }
        }
        public void CancelDownload(Book book)
        {
            try
            {
                if (BookUpdater.CurrentBook.ID == book.ID)
                {
                    book.Cancelled = true;

                    BookUpdater.CancelDownloadOperations();

                    // If internet connection is available, remove the current book and start download next one
                    if (Reachability.IsDefaultNetworkAvailable())
                    {
                        GetBookViewAndUpdateCollectionView(book.ID);
                    }
                    else
                    {
                        // Cancel current downloads if it's in progress
                        CancelAllDownloads();
                    }
                }
                else
                {
                    BookUpdater.RemoveBookFromDevice(book);
                    BookUpdater.Dequeue(book.ID);
                }

                RefreshTable();
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("BookshelfViewController - CancelDownload: {0}", ex.ToString());
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            BookUpdater.RegisterASIDelegate(this);

            RetrieveBooks();
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            updateMyBookTab = false;

            BookUpdater.RegisterASIDelegate(this);
        }
Ejemplo n.º 6
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            BookUpdater.RegisterASIDelegate(this);

            this.NavigationController.InteractivePopGestureRecognizer.Enabled = false;
        }
        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());
                }
            }
        }
Ejemplo n.º 8
0
        async public static void Check4Update()
        {
            if (BooksOnDeviceAccessor.GetBooks() != null)
            {
                List <Book> bookList = await eBriefingService.Run(() => eBriefingService.StartDownloadBooks());

                if (bookList != null)
                {
                    BookUpdater.DoesBooksNeedUpdate(bookList);
                }
            }
        }
        private void StartDownload(List <Book> bookList = null)
        {
            if (bookList != null)
            {
                BookUpdater.Enqueue(bookList);
            }

            // Only start only if it is not in progress
            if (!BookUpdater.InProgress)
            {
                BookUpdater.Start();
            }
        }
Ejemplo n.º 10
0
        protected override void RemoveBook(Book book)
        {
            UpdateUpdatesBadge();

            // Remove from update list
            if (BookUpdater.Books2Update != null)
            {
                BookUpdater.RemoveBookFromBooks2Update(book.ID);

                UpdateUpdatesBadge();
            }

            base.RemoveBook(book);
        }
        public void CancelAllDownloads()
        {
            if (BookUpdater.CurrentBook != null)
            {
                BookUpdater.CurrentBook.Cancelled = true;
            }

            BookUpdater.CancelDownloadOperations();

            RemovePendingBooks();

            BookUpdater.DownloadFinished();

            RefreshTable();
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            // Initialize controls
            if (isFirst)
            {
                isFirst = false;

                InitializeControls();
            }

            UpdateScreen(InterfaceOrientation);

            BookUpdater.RegisterASIDelegate(this);
        }
        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();
        }
Ejemplo n.º 14
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();
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            //for rotation
            UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();
            rotationNotification = NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UIDeviceOrientationDidChangeNotification"), DeviceOrientationDidChange);

            this.NavigationController.NavigationBar.SetBackgroundImage(UIImage.FromBundle("Assets/Backgrounds/navbar.png").CreateResizableImage(new UIEdgeInsets(0, 1, 0, 1)), UIBarMetrics.Default);
            this.NavigationController.InteractivePopGestureRecognizer.Enabled = false;

            BookUpdater.RegisterASIDelegate(this);

            if (isFirst)
            {
                InitializeControls();

                // Update new status
                UpdateBookStatus();
            }
            else
            {
                ExpandCollapseDashboard(false, false);
            }

            // floatMenu
            floatMenu                   = AppDelegate.Current.AddDashboardFloatMenu();
            floatMenu.SortEvent        += HandleSortEvent;
            floatMenu.CollapseEvent    += HandleCollapseEvent;
            floatMenu.ExpandEvent      += HandleExpandEvent;
            floatMenu.GoToFirstEvent   += HandleGoToFirstEvent;
            floatMenu.GoToCurrentEvent += HandleGoToCurrentEvent;

            // Reload data
            LoadData();

            isFirst = false;
        }
Ejemplo n.º 16
0
 protected virtual void RequestDidFinish(NSObject sender)
 {
     BookUpdater.RequestDidFinish(sender);
 }
Ejemplo n.º 17
0
 protected virtual void QueueDidFinish(NSObject sender)
 {
     BookUpdater.QueueDidFinish(sender);
 }