示例#1
0
        private void _loadingStatusBar_ShowMoreResultsClick(object sender, RoutedEventArgs e)
        {
            var packageItems = _loader?.GetCurrent() ?? Enumerable.Empty <PackageItemListViewModel>();

            UpdatePackageList(packageItems, refresh: true);
            _loadingStatusBar.ItemsLoaded = _loader?.State.ItemsCount ?? 0;

            var desiredVisibility = EvaluateStatusBarVisibility(_loader, _loader.State);

            if (_loadingStatusBar.Visibility != desiredVisibility)
            {
                _loadingStatusBar.Visibility = desiredVisibility;
            }
        }
示例#2
0
        private async Task <IEnumerable <PackageItemListViewModel> > LoadNextPageAsync(IItemLoader <PackageItemListViewModel> currentLoader, CancellationToken token)
        {
            var progress = new Progress <IItemLoaderState>(
                s => HandleItemLoaderStateChange(currentLoader, s));

            // trigger loading
            await currentLoader.LoadNextAsync(progress, token);

            // run till first results are ready
            for (var state = currentLoader.State;
                 state.LoadingStatus == LoadingStatus.Loading && state.ItemsCount == 0;
                 state = currentLoader.State)
            {
                token.ThrowIfCancellationRequested();
                await currentLoader.UpdateStateAsync(progress, token);
            }

            return(currentLoader.GetCurrent());
        }