Exemple #1
0
        /// <summary>
        ///  Handle the LazyLoading of items
        /// </summary>
        /// <param name="isInitialized">Is called with Flipview's Initialization</param>
        /// <returns>Task (void)</returns>

        async private Task LoadNextItemAsync(bool isInitialized = true)
        {
            try
            {
                if (this.ItemsSource != null && CanIncrementalLoadigTrigger())
                {
                    IsBusy = true;
                    ISupportIncrementalLoading incrementalLoadingInterface = this.ItemsSource as ISupportIncrementalLoading;
                    if (incrementalLoadingInterface != null)
                    {
                        if (incrementalLoadingInterface.HasMoreItems)
                        {
                            if (!isInitialized)
                            {
                                await incrementalLoadingInterface.LoadMoreItemsAsync(1);

                                return;
                            }

                            for (int i = 1; i <= this.IncrementalLoadingThreshold; i++)
                            {
                                await incrementalLoadingInterface.LoadMoreItemsAsync((uint)this.DataFetchSize);
                            }
                        }
                    }
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        private async void OnItemAppearing(object sender, ItemVisibilityEventArgs e)
        {
            if (itemsSource == null || incrementalLoading == null)
            {
                return;
            }

            int position = itemsSource.IndexOf(e.Item);

            if (PreloadCount <= 0)
            {
                PreloadCount = 1;
            }

            int preloadIndex = Math.Max(itemsSource.Count - PreloadCount, 0);

            if ((position > lastPosition || (position == itemsSource.Count - 1)) && (position >= preloadIndex))
            {
                lastPosition = position;

                if (!incrementalLoading.IsLoadingIncrementally &&
                    !IsRefreshing &&
                    incrementalLoading.HasMoreItems)
                {
                    await incrementalLoading.LoadMoreItemsAsync();
                }
            }
        }
Exemple #3
0
        public void LoadMoreItems(uint count)
        {
            Debug.Assert(_loadingOperation == null, "Expected _loadingOperation == null.");

            _loadingOperation = _incrementalItemsSource.LoadMoreItemsAsync(count);

            if (_loadingOperation != null)
            {
                _loadingOperation.Completed = OnLoadingOperationCompleted;
            }
        }
        private async void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            //incremental loading
            if (incrementalCollection != null &&
                scroll.VerticalOffset / scroll.ScrollableHeight >= INCREMENTAL_SCROLL_FACTOR &&
                !loadingIncremental &&
                incrementalCollection.HasMoreItems)
            {
                loadingIncremental = true;
                await incrementalCollection.LoadMoreItemsAsync(30);     //TODO choose your pagination increment for ISupportIncrementalLoading

                loadingIncremental = false;
            }
        }
Exemple #5
0
 public IncrementalLoadingFlipView()
 {
     this.SelectionChanged += (sender, e) =>
     {
         if (this.SelectedIndex == this.Items.Count - 3)
         {
             ISupportIncrementalLoading list = this.ItemsSource as ISupportIncrementalLoading;
             if (list?.HasMoreItems == true)
             {
                 list?.LoadMoreItemsAsync((uint)this.Items.Count);
             }
         }
     };
 }
Exemple #6
0
        protected override async void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            base.OnPropertyChanged(propertyName);

            if (propertyName == ItemsSourceProperty.PropertyName)
            {
                itemsSource = ItemsSource as IList;
                if (itemsSource == null)
                {
                    throw new Exception($"{nameof(IncrementalListView)} requires that {nameof(itemsSource)} be of type IList");
                }
                incrementalLoading = ItemsSource as ISupportIncrementalLoading;
                if (incrementalLoading == null)
                {
                    throw new Exception($"{nameof(IncrementalListView)} requires that {nameof(itemsSource)} be of type ISupportIncrementalLoading");
                }

                await incrementalLoading.LoadMoreItemsAsync();
            }
        }
Exemple #7
0
 public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
 {
     return(_delegate.LoadMoreItemsAsync(count));
 }
Exemple #8
0
        /// <summary>
        /// Load more items from the source
        /// </summary>
        /// <param name="count">number of items to load</param>
        /// <returns>Async operation of LoadMoreItemsResult</returns>
        /// <exception cref="NotImplementedException">Not implemented yet...</exception>
        public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
        {
            ISupportIncrementalLoading sil = _source as ISupportIncrementalLoading;

            return(sil?.LoadMoreItemsAsync(count));
        }
        /// <summary>
        /// Invoked to load more items from the source.
        /// </summary>
        /// <param name="count">number of items to load</param>
        /// <returns>Async operation of LoadMoreItemsResult</returns>
        public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count)
        {
            ISupportIncrementalLoading sourceAsSupportIncrementalLoading = _sourceCollection as ISupportIncrementalLoading;

            return(sourceAsSupportIncrementalLoading?.LoadMoreItemsAsync(count));
        }