public async override void ViewDidLoad() { this.InitLeftButton(); CollectionView.BackgroundColor = UIColor.White; try { CollectionView.RegisterClassForCell(typeof(TagCell), new NSString("tagcell")); CollectionView.Delegate = new ViewDelegate(this); var response = await ServiceProxy.GetAllTagsByPopularity(page, 100); _tags = response.items; _hasMoreData = response.has_more; CollectionView.ReloadData(); } catch (Exception ex) { this.UnhandledError(ex); } }
public async override void Scrolled(UIScrollView scrollView) { if (scrollView.Dragging && _c._hasMoreData) { float threshold = scrollView.ContentSize.Height - scrollView.Bounds.Height; if (scrollView.ContentOffset.Y > threshold - 160 && !_c._pagingActionInProgress) { Console.WriteLine("starting infinite loading"); _c._pagingActionInProgress = true; BaseResponse <Tag> response = null; try { response = await ServiceProxy.GetAllTagsByPopularity(_c.page + 1, 100); } catch (Exception ex) { Console.WriteLine(ex); NSTimer.CreateScheduledTimer(0.6f, delegate { _c._pagingActionInProgress = false; }); return; } _c.page++; _c._hasMoreData = response.has_more; int currentCount = _c._tags.Count; _c._tags.AddRange(response.items); _c.CollectionView.PerformBatchUpdates(delegate { var indexPaths = Enumerable.Range(currentCount, response.items.Count).Select(r => NSIndexPath.FromItemSection(r, 0)); _c.CollectionView.InsertItems(indexPaths.ToArray()); }, null); NSTimer.CreateScheduledTimer(0.6f, delegate { _c._pagingActionInProgress = false; }); } } }
public void GetTags() { var tags = ServiceProxy.GetAllTagsByPopularity(1, "man").Result; Assert.IsNotEmpty(tags.items); }