Ejemplo n.º 1
0
        protected override async Task LoadData(bool isRefresh, bool add = false, int offset = 0)
        {
            if (ItemsLoaded && !isRefresh && !add)
            {
                return;
            }

            try
            {
                if (!add)
                {
                    SetProgressBar("Getting comments...");
                }

                IsLoadingMore = add;

                var response = await _vidMeClient.GetCommentsAsync(Video.VideoId, SortDirection.Ascending, offset);

                if (Items == null || !add)
                {
                    Items = new ObservableCollection <CommentViewModel>();
                }

                Items.AddRange(response.Comments.Select(x => new CommentViewModel(x, this)));

                CanLoadMore = response.Page.Total > Items.Count;
                ItemsLoaded = true;
            }
            catch (Exception ex)
            {
                HasErrors = true;
                Log.ErrorException("LoadData(Comments)", ex);
            }

            IsLoadingMore = false;
            SetProgressBar();
        }