コード例 #1
0
        void Remove(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.OldStartingIndex;

            if (startIndex < 0)
            {
                // INCC implementation isn't giving us enough information to know where the removed items were in the
                // collection. So the best we can do is a complete reload
                Reload();
                return;
            }

            if (ReloadRequired())
            {
                Reload();
                return;
            }

            // Removing 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();

            // Since we have a start index, we can be more clever about removing the item(s) (and get the nifty animations)
            var count = args.OldItems.Count;

            // Queue up the updates to the UICollectionView
            Update(() => _collectionView.DeleteSections(CreateIndexSetFrom(startIndex, count)));
        }
コード例 #2
0
        void Remove(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.OldStartingIndex;

            if (startIndex < 0)
            {
                // INCC implementation isn't giving us enough information to know where the removed items were in the
                // collection. So the best we can do is a ReloadData()
                Reload();
                return;
            }

            // If we have a start index, we can be more clever about removing the item(s) (and get the nifty animations)
            var count = args.OldItems.Count;

            _collectionView.PerformBatchUpdates(() =>
            {
                _collectionView.DeleteItems(CreateIndexesFrom(startIndex, count));

                if (!_grouped && _collectionView.NumberOfSections() != GroupCount)
                {
                    // We had a non-grouped list with items, and we're removing the last one;
                    // we also need to remove the group it was in
                    _collectionView.DeleteSections(new NSIndexSet(0));
                }
            }, null);
        }