Exemple #1
0
 /// <summary>
 /// Fired when the screen mode changes.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnScreenModeChanged(object sender, OnScreenModeChangedArgs e)
 {
     lock (m_postsLists)
     {
         Visibility flipViewMenuVis = m_host.CurrentScreenMode() == ScreenMode.Single ? Visibility.Visible : Visibility.Collapsed;
         foreach (Post post in m_postsLists)
         {
             post.FlipViewMenuButton = flipViewMenuVis;
         }
     }
 }
Exemple #2
0
 public void OnNavigatingTo()
 {
     if (m_host.CurrentScreenMode() == ScreenMode.Split)
     {
         ui_slidingImageControl.BeginAnimation();
     }
 }
Exemple #3
0
        public async void OnNavigatingTo()
        {
            if (m_host.CurrentScreenMode() == ScreenMode.Split)
            {
                ui_slidingImageControl.BeginAnimation();
            }

            // Set the status bar color and get the size returned. If it is not 0 use that to move the
            // color of the page into the status bar.
            double statusBarHeight = await m_host.SetStatusBar(null, 0);

            ui_contentRoot.Margin = new Thickness(0, -statusBarHeight, 0, 0);
        }
Exemple #4
0
        /// <summary>
        /// Update the posts in flip view. Staring at the index given and going until the list is empty.
        /// </summary>
        /// <param name="startingPos"></param>
        /// <param name="newPosts"></param>
        private async void UpdatePosts(int startingPos, IReadOnlyList <Post> newPosts)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                var flipViewMenuVis = _host.CurrentScreenMode() == ScreenMode.Single ? Visibility.Visible : Visibility.Collapsed;

                // Grab the list lock
                lock (_postsLists)
                {
                    // If we are currently in a deferred scenario then we need to handle updates
                    // differently since the list won't match the list that is expected
                    if (_deferredPostList.Count != 0)
                    {
                        if (_postsLists.Count <= 0 || newPosts.Count <= 0 ||
                            !_postsLists[0].Context.Post.Id.Equals(newPosts[0].Id))
                        {
                            return;
                        }
                        // The current post is updated, so update it.
                        // We can't replace the time because flip view will freak out
                        // so just update whatever UI we need to update.
                        _postsLists[0].Context.Post.Likes               = newPosts[0].Likes;
                        _postsLists[0].Context.Post.SubTextLine1        = newPosts[0].SubTextLine1;
                        _postsLists[0].Context.Post.SubTextLine2PartOne = newPosts[0].SubTextLine2PartOne;
                        _postsLists[0].Context.Post.SubTextLine2PartTwo = newPosts[0].SubTextLine2PartTwo;
                        _postsLists[0].Context.Post.Domain              = newPosts[0].Domain;
                        _postsLists[0].Context.Post.Score               = newPosts[0].Score;

                        // We have done all we want to do, leave now.
                        return;
                    }

                    // If the list is currently empty we want to only load the first element and defer the rest of the
                    // elements. If the target post is -1 we load the first element, if not we load it only.
                    var deferLoadPosts  = _postsLists.Count == 0;
                    var deferTargetPost = _targetPost;
                    _targetPost         = null;
                    if (deferLoadPosts)
                    {
                        // If we are doing a defer make sure we have a target
                        if (string.IsNullOrWhiteSpace(deferTargetPost) && newPosts.Count > 0)
                        {
                            deferTargetPost = newPosts[0].Id;
                        }
                    }

                    // Now setup the post update
                    var insertIndex = startingPos;

                    // Set up the objects for the UI
                    foreach (var post in newPosts)
                    {
                        if (post == null)
                        {
                            continue;
                        }

                        // Check if we are adding or inserting.
                        var isReplace = insertIndex < _postsLists.Count;

                        if (isReplace)
                        {
                            if (_postsLists[insertIndex].Context.Post.Id.Equals(post.Id))
                            {
                                // We can't replace the time because flip view will freak out
                                // so just update whatever UI we need to update.
                                _postsLists[insertIndex].Context.Post.Likes               = post.Likes;
                                _postsLists[insertIndex].Context.Post.SubTextLine1        = post.SubTextLine1;
                                _postsLists[insertIndex].Context.Post.SubTextLine2PartOne = post.SubTextLine2PartOne;
                                _postsLists[insertIndex].Context.Post.SubTextLine2PartTwo = post.SubTextLine2PartTwo;
                                _postsLists[insertIndex].Context.Post.Domain              = post.Domain;
                                _postsLists[insertIndex].Context.Post.Score               = post.Score;
                            }
                            else
                            {
                                // Replace the entire post if it brand new
                                _postsLists[insertIndex].Context.Post = post;
                            }
                        }
                        else
                        {
                            // If we are deferring posts only add the target
                            if (deferLoadPosts)
                            {
                                if (post.Id.Equals(deferTargetPost))
                                {
                                    // Try catch is a work around for bug https://github.com/QuinnDamerell/Baconit/issues/53
                                    try
                                    {
                                        _postsLists.Add(new FlipViewPostItem(_host, _collector, post, _targetComment));
                                    }
                                    catch (Exception e)
                                    {
                                        TelemetryManager.ReportUnexpectedEvent(this, "UpdatePosts", e);
                                        App.BaconMan.MessageMan.DebugDia("Adding to postList failed! (deferLoadPosts)", e);
                                    }
                                }

                                // Add it to the deferred list, also add the deferred post so we know
                                // where it is in the list.
                                _deferredPostList.Add(post);
                            }
                            else
                            {
                                // Otherwise, just add it.
                                // Try catch is a work around for bug https://github.com/QuinnDamerell/Baconit/issues/53
                                try
                                {
                                    _postsLists.Add(new FlipViewPostItem(_host, _collector, post, _targetComment));
                                }
                                catch (Exception e)
                                {
                                    TelemetryManager.ReportUnexpectedEvent(this, "UpdatePosts", e);
                                    App.BaconMan.MessageMan.DebugDia("Adding to postList failed! (!deferLoadPosts)", e);
                                }
                            }
                        }

                        // Set the menu button
                        post.FlipViewMenuButton = flipViewMenuVis;

                        // Add one to the insert index
                        insertIndex++;
                    }

                    // If the item source hasn't been set yet do it now.
                    if (ui_flipView.ItemsSource == null)
                    {
                        ui_flipView.ItemsSource = _postsLists;
                    }
                }

                // Hide the loading overlay if it is visible
                HideFullScreenLoading();
            });
        }