Пример #1
0
        private async Task LoadLibraryDataAsync(Dictionary<string, string> filterDicts, OrderType orderType = OrderType.LASTEST)
        {
            if (pageParams == null)
            {
                return;
            }

            indicator.IsActive = true;
            page = 1;

            await ChannelAPI.GetLibraryList(data =>
            {
                viewModel.VideoCount = data.Count;
                viewModel.GroupList.Clear();

                if (data.Videos != null)
                {
                    RemoveLoadMoreControl();
                    for (int i = 0; i < data.Videos.Length; i++)
                    {
                        int groupIndex = i / 10;
                        if (viewModel.GroupList.Count > groupIndex)
                        {
                            var group = viewModel.GroupList[groupIndex];
                            group.Group.Add(CopyVideoData(data.Videos[i]));
                        }
                        else
                        {
                            VideoGroup group = new VideoGroup();
                            group.Group.Add(CopyVideoData(data.Videos[i]));
                            viewModel.GroupList.Add(group);
                        }
                    }

                    if(data.Videos.Length == limit)
                    {
                        EnusureLoadMoreControl();
                    }
                }

                // lazy init
                //
                this.FindName("contentScrollViwer");
                this.FindName("videoCountText");
                page++;

                indicator.IsActive = false;

            }, error =>
            {
                //indicator.IsActive = false;
            },
            pageParams.ChannelId,
            orderType,
            filterDicts,
            page,
            limit);
        }
Пример #2
0
        private async void loadMore_Loaded(object sender, RoutedEventArgs e)
        {
            if(indicator.IsActive)
            {
                return;
            }

            indicator.IsActive = true;
            await ChannelAPI.GetLibraryList(data => {

                if (data.Videos != null)
                {
                    RemoveLoadMoreControl();
                    int baseIndex = viewModel.GroupList.Count;

                    for (int i = 0; i < data.Videos.Length; i++)
                    {
                        int groupIndex = baseIndex + (i / 10);
                        if (viewModel.GroupList.Count > groupIndex)
                        {
                            var group = viewModel.GroupList[groupIndex];
                            group.Group.Add(CopyVideoData(data.Videos[i]));
                        }
                        else
                        {
                            VideoGroup group = new VideoGroup();
                            group.Group.Add(CopyVideoData(data.Videos[i]));
                            viewModel.GroupList.Add(group);
                        }
                    }

                    if (data.Videos.Length == limit)
                    {
                        EnusureLoadMoreControl();
                        page++;
                    }

                    indicator.IsActive = false;
                }

            }, error => {
                indicator.IsActive = false;
            },
            pageParams.ChannelId,
            GetOrderType(),
            GetFilters(),
            page,
            limit);
        }