private int[] move(MoveRowWithinExistingSectionsCollectionChange <TModel> change)
        {
            var oldSectionWasRemoved = remove(change.OldIndex);

            tableView.InsertRows(change.Index.ToIndexPaths(), UITableViewRowAnimation.Automatic);

            return(oldSectionWasRemoved
                ? new[] { change.Index.Section }
                : new[] { change.OldIndex.Section, change.Index.Section });
        }
        private int[] move(MoveRowWithinExistingSectionsCollectionChange <TModel> change)
        {
            var oldSectionWasRemoved = remove(change.OldIndex);

            tableView.InsertRows(change.Index.ToIndexPaths(), UITableViewRowAnimation.Automatic);

            if (oldSectionWasRemoved)
            {
                // The index of the section which needs refreshing must be the index before the changes happen.
                // The index of the target section might change if the old section was in front of the target one
                // and the old one was removed. The original index of the target section would then be a one more
                // than the index after hte operation (which is the value of `change.Index.Section`).
                return(new[] { change.Index.Section + change.OldIndex.Section <= change.Index.Section ? 1 : 0 });
            }

            return(new[] { change.OldIndex.Section, change.Index.Section });
        }
        private void moveRowWithinExistingSections(MoveRowWithinExistingSectionsCollectionChange <TModel> moveRowWithinExistingSections)
        {
            var sectionsCountBeforeUpdate = sectionsIndexes.Count;
            var oldIndex        = mapSectionIndexToAdapterIndex(moveRowWithinExistingSections.OldIndex);
            var oldSectionIndex = sectionsIndexes[moveRowWithinExistingSections.OldIndex.Section] + HeaderOffset;

            updateSectionIndexes();
            var oldSectionWasDeleted = sectionsCountBeforeUpdate != sectionsIndexes.Count;

            if (oldSectionWasDeleted)
            {
                NotifyItemRemoved(oldSectionIndex);
            }

            var newIndex = mapSectionIndexToAdapterIndex(moveRowWithinExistingSections.Index);

            NotifyItemMoved(oldIndex, newIndex);
        }