示例#1
0
        /// <summary>
        /// Fired when the collector state is updated.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void Collector_OnCollectorStateChange(object sender, CollectorStateChangeArgs args)
        {
            // Set loading if needed.
            ToggleLoadingBar(args.State == CollectorState.Updating || args.State == CollectorState.Extending);

            // Toggle the suppress depending on if we are updating, extending, or idle
            ui_postList.SuppressEndOfListEvent = args.State == CollectorState.Updating || args.State == CollectorState.Extending;

            // If we had an error show a message.
            if (_isVisible && args.State == CollectorState.Error)
            {
                if (args.ErrorState == CollectorErrorState.ServiceDown)
                {
                    App.BaconMan.MessageMan.ShowRedditDownMessage();
                }
                else
                {
                    App.BaconMan.MessageMan.ShowMessageSimple("That's Not Right", "We can't update this subreddit right now, check your Internet connection.");
                }
            }

            // Show no posts if nothing was loaded
            if (args.State != CollectorState.Idle && args.State != CollectorState.FullyExtended)
            {
                return;
            }

            var postLoaded = _collector.GetCurrentPosts().Count != 0;
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                ui_noPostText.Visibility = postLoaded ? Visibility.Collapsed : Visibility.Visible;
            });
        }
示例#2
0
 /// <summary>
 /// Fired when the collector state changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectorStateChange(object sender, CollectorStateChangeArgs e)
 {
     if (e.State == CollectorState.Error)
     {
         // If we get an error we are done.
         ReleaseDeferral();
     }
 }
        /// <summary>
        /// Fired when the collector state changed for the either
        /// </summary>
        /// <param name="type"></param>
        /// <param name="e"></param>
        private void Collector_OnCollectorStateChange(UpdateTypes type, CollectorStateChangeArgs e)
        {
            if (e.State != CollectorState.Error)
            {
                return;
            }
            // We had an error. This is the end of the line, kill the deferral
            ReleaseDeferral(type);

            // And try to set isRunning
            UnSetIsRunningIfDone();
        }
示例#4
0
        private async void Collector_OnCollectorStateChange(object sender, CollectorStateChangeArgs e)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // Show or hide the progress bar
                ToggleProgressBar(e.State == CollectorState.Updating || e.State == CollectorState.Extending);

                if (e.State == CollectorState.Error && e.ErrorState == CollectorErrorState.ServiceDown)
                {
                    App.BaconMan.MessageMan.ShowRedditDownMessage();
                }
            });
        }
示例#5
0
 /// <summary>
 /// Fired when the collection state is changing
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void CurrentSubCollector_OnCollectorStateChange(object sender, CollectorStateChangeArgs e)
 {
     await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (e.State == CollectorState.Idle || e.State == CollectorState.Error || e.State == CollectorState.FullyExtended)
         {
             HideProgressBar(SearchResultTypes.Subreddit);
         }
         else
         {
             ShowProgressBar(SearchResultTypes.Subreddit);
         }
     });
 }
示例#6
0
        /// <summary>
        /// Fired when the comment list is loading
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void CommentCollector_OnCollectorStateChange(object sender, CollectorStateChangeArgs e)
        {
            // Jump to the UI thread
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                // Kill anything we have
                ui_commentLoadingBar.IsIndeterminate = false;
                ui_commentLoadingBar.Visibility      = Visibility.Collapsed;
                ui_commentLoadingRing.IsActive       = false;
                ui_commentLoadingRing.Visibility     = Visibility.Collapsed;

                // Set the new loading
                if (e.State == CollectorState.Extending || e.State == CollectorState.Updating)
                {
                    if (_mCommentList.Count == 0)
                    {
                        ui_commentLoadingRing.IsActive   = true;
                        ui_commentLoadingRing.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        ui_commentLoadingBar.IsIndeterminate = true;
                        ui_commentLoadingBar.Visibility      = Visibility.Visible;
                    }
                }

                // Check for no comments
                if ((e.State == CollectorState.Idle || e.State == CollectorState.FullyExtended) && _mCommentList.Count == 0 && e.NewPostCount == 0)
                {
                    ui_commentNoPostsText.Visibility = Visibility.Visible;
                    ui_commentList.Visibility        = Visibility.Collapsed;
                }
                else if (e.State == CollectorState.Idle || e.State == CollectorState.FullyExtended)
                {
                    ui_commentNoPostsText.Visibility = Visibility.Collapsed;
                    ui_commentList.Visibility        = Visibility.Visible;
                }
            });
        }
示例#7
0
        private async void CommentCollector_OnCollectorStateChange(object sender, CollectorStateChangeArgs e)
        {
            switch (e.State)
            {
            // #todo handle when there are no more
            case CollectorState.Idle:
            case CollectorState.FullyExtended:
                // When we are idle hide the loading message.
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    // Check if we have any comments
                    if (e.NewPostCount == 0 && Comments.Count == 0)
                    {
                        _post.ShowCommentLoadingMessage       = Visibility.Visible;
                        _post.ShowCommentsErrorMessage        = "No Comments";
                        _post.FlipViewShowLoadingMoreComments = false;
                    }
                    else
                    {
                        _post.ShowCommentLoadingMessage       = Visibility.Collapsed;
                        _post.FlipViewShowLoadingMoreComments = false;
                    }
                });

                break;

            case CollectorState.Error:
                // Show an error message if we error
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    _post.ShowCommentsErrorMessage        = "Error Loading Comments";
                    _post.FlipViewShowLoadingMoreComments = false;
                });

                break;
            }
        }
 /// <summary>
 /// Fired when the collector state changed for the band
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectorStateChangeBand(object sender, CollectorStateChangeArgs e)
 {
     Collector_OnCollectorStateChange(UpdateTypes.Band, e);
 }
 /// <summary>
 /// Fired when the collector state changed for the lock screen
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectorStateChangeDesktop(object sender, CollectorStateChangeArgs e)
 {
     Collector_OnCollectorStateChange(UpdateTypes.Desktop, e);
 }
 /// <summary>
 /// Fired when the collector state changed for the lock screen
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Collector_OnCollectorStateChangeLockScreen(object sender, CollectorStateChangeArgs e)
 {
     Collector_OnCollectorStateChange(UpdateTypes.LockScreen, e);
 }