示例#1
0
        /// <summary>
        /// Load review
        /// </summary>
        /// <returns></returns>
        private async Task loadReview()
        {
            if (movie != null)
            {
                bool fromDormant = false;
                reviewParser = new ReviewParser(movie);
                ReviewProgressBar.IsIndeterminate = true;
                ReviewProgressBar.Visibility      = System.Windows.Visibility.Visible;
                reviewNewLoad = true;

                try
                {
                    await reviewParser.getReview();

                    reviewLongListSelector.ItemsSource = reviewParser.reviewCollection;
                    if (reviewLongListSelector.ItemsSource.Count == 0)
                    {
                        reviewTextBlock.Visibility = System.Windows.Visibility.Visible;
                    }
                    ReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                }
                catch (TaskCanceledException)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        ReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        if (!reviewParser.isCanceled())
                        {
                            reviewLoaded = false;
                            MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                        }
                    }
                }
                catch (Exception)
                {
                    if (App.isFromDormant)
                    {
                        fromDormant = true;
                    }
                    else
                    {
                        reviewLoaded = false;
                        ReviewProgressBar.Visibility = System.Windows.Visibility.Collapsed;
                        MessageBoxResult result = MessageBox.Show(AppResources.ConnectionError, "", MessageBoxButton.OK);
                    }
                }

                if (fromDormant)
                {
                    App.isFromDormant = false;
                    await loadReview();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Load more review
        /// </summary>
        /// <returns></returns>
        private async Task loadMoreReview()
        {
            if (!reviewParser.hasMoreReview)
            {
                noReviewTextBlock.Visibility = System.Windows.Visibility.Visible;
                await Task.Delay(2000);

                noReviewTextBlock.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                bool fromDormant = false;
                ReviewProgressBar.IsIndeterminate = true;
                ReviewProgressBar.Visibility      = System.Windows.Visibility.Visible;
                reviewNewLoad = true;

                try
                {
                    await reviewParser.loadMore();

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

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