void Replace(NotifyCollectionChangedEventArgs args)
        {
            var startIndex = args.NewStartingIndex > -1 ? args.NewStartingIndex : IndexOf(args.NewItems[0]);

            startIndex = AdjustPositionForHeader(startIndex);
            var newCount = args.NewItems.Count;

            if (newCount == args.OldItems.Count)
            {
                // We are replacing one set of items with a set of equal size; we can do a simple item or range
                // notification to the adapter
                if (newCount == 1)
                {
                    _notifier.NotifyItemChanged(this, startIndex);
                }
                else
                {
                    _notifier.NotifyItemRangeChanged(this, startIndex, newCount);
                }

                return;
            }

            // The original and replacement sets are of unequal size; this means that everything currently in view will
            // have to be updated. So we just have to use NotifyDataSetChanged and let the RecyclerView update everything
            _notifier.NotifyDataSetChanged();
        }
Пример #2
0
 public void NotifyItemChanged(IItemSource group, int localIndex)
 {
     localIndex = GetAbsolutePosition(group, localIndex);
     notifier.NotifyItemChanged(this, localIndex);
 }