예제 #1
0
        void Add(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : _groupSource.IndexOf(args.NewItems[0]);
            var count      = args.NewItems.Count;

            // Adding a group will change the section index for all subsequent groups, so the easiest thing to do
            // is to reset all the group tracking to get it up-to-date
            ResetGroupTracking();

            if (NotLoadedYet())
            {
                _collectionView.ReloadData();
                return;
            }

            if (_collectionView.NumberOfSections() == 0)
            {
                // Okay, we're going from completely empty to more than 0 items; there's an iOS bug which apparently
                // will just crash if we call InsertItems here, so we have to do ReloadData.
                _collectionView.ReloadData();
                return;
            }

            _collectionView.InsertSections(CreateIndexSetFrom(startIndex, count));
        }
        void Add(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : _groupSource.IndexOf(args.NewItems[0]);
            var count      = args.NewItems.Count;

            // Adding a group will change the section index for all subsequent groups, so the easiest thing to do
            // is to reset all the group tracking to get it up-to-date
            ResetGroupTracking();

            _collectionView.InsertSections(CreateIndexSetFrom(startIndex, count));
        }
예제 #3
0
        void Add(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : _itemsSource.IndexOf(args.NewItems[0]);
            var count      = args.NewItems.Count;

            _collectionView.PerformBatchUpdates(() =>
            {
                if (!_grouped && _collectionView.NumberOfSections() != GroupCount)
                {
                    // We had an empty non-grouped list, and now we're trying to add an item;
                    // we need to give it a section as well
                    _collectionView.InsertSections(new NSIndexSet(0));
                }

                _collectionView.InsertItems(CreateIndexesFrom(startIndex, count));
            }, null);
        }
예제 #4
0
        async Task Add(NotifyCollectionChangedEventArgs args)
        {
            if (ReloadRequired())
            {
                await Reload();

                return;
            }

            var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : _groupSource.IndexOf(args.NewItems[0]);
            var count      = args.NewItems.Count;

            // Adding a group will change the section index for all subsequent groups, so the easiest thing to do
            // is to reset all the group tracking to get it up-to-date
            ResetGroupTracking();

            // Queue up the updates to the UICollectionView
            BatchUpdate(() => _collectionView.InsertSections(CreateIndexSetFrom(startIndex, count)));
        }