Beispiel #1
0
        /// <summary>
        /// Load short review
        /// </summary>
        /// <returns></returns>
        private async Task loadShortReview()
        {
            if (movie != null)
            {
                bool fromDormant = false;
                shortReviewParser = new ShortReviewHtmlParser(movie);
                ShortReviewProgressBar.IsIndeterminate = true;
                ShortReviewProgressBar.Visibility      = System.Windows.Visibility.Visible;
                shortReviewNewLoad = true;

                try
                {
                    await shortReviewParser.getShortReview();

                    shortReviewSelector.ItemsSource = shortReviewParser.shortReviewCollection;
                    if (shortReviewSelector.ItemsSource.Count == 0)
                    {
                        shortReviewTextBlock.Visibility = System.Windows.Visibility.Visible;
                    }
                    ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                }
                catch (TaskCanceledException)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        if (!shortReviewParser.isCanceled())
                        {
                            shortReviewLoaded = false;
                            MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                        }
                    }
                }
                catch (Exception)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        shortReviewLoaded = false;
                        MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                    }
                }

                if (fromDormant)
                {
                    App.isFromDormant = false;
                    await loadShortReview();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Load more short review
        /// </summary>
        /// <returns></returns>
        private async Task loadMoreShortReview()
        {
            if (!shortReviewParser.hasMoreReview)
            {
                noShortReviewTextBlock.Visibility = System.Windows.Visibility.Visible;
                await Task.Delay(2000);

                noShortReviewTextBlock.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                bool fromDormant = false;
                ShortReviewProgressBar.IsIndeterminate = true;
                ShortReviewProgressBar.Visibility      = System.Windows.Visibility.Visible;
                shortReviewNewLoad = true;

                try
                {
                    await shortReviewParser.loadMore();

                    ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                }
                catch (TaskCanceledException)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        if (!shortReviewParser.isCanceled())
                        {
                            MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                        }
                    }
                }
                catch (Exception)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ShortReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                    }
                }

                if (fromDormant)
                {
                    App.isFromDormant = false;
                    await loadMoreShortReview();
                }
            }
        }