public static void LoadComments(FBEntity Item, ListBox lstComments, Button btnCommentsMore, bool nextpage) { string lastid = null; var offset = 0; if (nextpage) { var current = lstComments.ItemsSource as VirtualizedCollection<Comment>; if (current != null) { lastid = current.Last().Id; offset = current.Count; } } LoadingManager.Start(); Item.GetComments(list => { ThreadHelper.RunOnUI(() => { var loadmoreenabled = nextpage ? list.Any() : list.Count >= FBDataAccess.LIST_LIMIT_SIZE; if (lastid.HasValue()) { var current = lstComments.ItemsSource as VirtualizedCollection<Comment>; if (current != null) { list = new VirtualizedCollection<Comment>(current.Concat(list).Distinct(a => a.Id)); } } lstComments.ItemsSource = list; btnCommentsMore.Visibility = loadmoreenabled.ToVisibility(); btnCommentsMore.IsEnabled = true; }); LoadingManager.Stop(); }, lastid, offset); }
private void LoadFriends(string f = null) { if (lstFriends_Loading) return; lstFriends_Loading = true; LoadingManager.Start(); Item.GetFriends(list => { ThreadHelper.RunOnUI(() => { if (f.HasValue()) { list = new VirtualizedCollection<User>(list.Where(a => a.Matches(f))); } lstFriends.ItemsSource = list; lstFriends_Loading = false; LoadingManager.Stop(); lstFriends.Focus(); }); }); }
void LoadWallPosts(bool nextpage = false) { DateTime? until = null; if (nextpage) { var current = lstWallPosts.ItemsSource as VirtualizedCollection<FeedItem>; if (current != null) { until = current.Last().Date; } } LoadingManager.Start(); Item.GetWallFeed(list => { ThreadHelper.RunOnUI(() => { var loadmoreenabled = nextpage ? list.Any() : list.Count >= FBDataAccess.LIST_LIMIT_SIZE; if (until.HasValue) { var current = lstWallPosts.ItemsSource as VirtualizedCollection<FeedItem>; if (current != null) { list = new VirtualizedCollection<FeedItem>(current.Concat(list).Distinct(a => a.Id)); } } lstWallPosts.ItemsSource = list; btnWallPostsMore.Visibility = loadmoreenabled.ToVisibility(); btnWallPostsMore.IsEnabled = true; LoadingManager.Stop(); }); }, until); }