protected virtual void ReloadSection(nint section, NotifyCollectionChangedEventArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } switch (args.Action) { case NotifyCollectionChangedAction.Add: CollectionView.PerformBatchUpdates(() => CollectionView.InsertItems(args.ToNewIndexPaths(section)), null); break; case NotifyCollectionChangedAction.Move: CollectionView.MoveItem(args.ToOldIndexPath(section), args.ToNewIndexPath(section)); break; case NotifyCollectionChangedAction.Replace: CollectionView.PerformBatchUpdates(() => CollectionView.ReloadItems(args.ToNewIndexPaths(section)), null); break; case NotifyCollectionChangedAction.Remove: CollectionView.PerformBatchUpdates(() => CollectionView.DeleteItems(args.ToOldIndexPaths(section)), null); break; default: CollectionView.ReloadSections(NSIndexSet.FromIndex(section)); break; } }
protected virtual void ReloadSection( nint section, [NotNull] NotifyCollectionChangedEventArgs args, UITableViewRowAnimation withRowAnimation = UITableViewRowAnimation.Automatic) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (TableViewWeakReference.TryGetTarget(out var tableView)) { switch (args.Action) { case NotifyCollectionChangedAction.Add: tableView.SupportPerformBatchUpdates(() => tableView.InsertRows(args.ToNewIndexPaths(section), withRowAnimation)); break; case NotifyCollectionChangedAction.Move: tableView.MoveRow(args.ToOldIndexPath(section), args.ToNewIndexPath(section)); break; case NotifyCollectionChangedAction.Replace: tableView.SupportPerformBatchUpdates(() => tableView.ReloadRows(args.ToNewIndexPaths(section), withRowAnimation)); break; case NotifyCollectionChangedAction.Remove: tableView.SupportPerformBatchUpdates(() => tableView.DeleteRows(args.ToOldIndexPaths(section), withRowAnimation)); break; default: tableView.ReloadSections(NSIndexSet.FromIndex(section), withRowAnimation); break; } } }