private void DispatchAdditions <T>(List <PostponedUpdate> postponedUpdates, MvxObservableCollection <T> updateCallback, IList <T> source, int start, int count, int globalIndex) { if (!mDetectMoves) { //updateCallback.onInserted(start, count); updateCallback.InsertRange(start, source.Skip(start).Take(count)); return; } for (int i = count - 1; i >= 0; i--) { int status = mNewItemStatuses[globalIndex + i] & FLAG_MASK; switch (status) { case 0: // real addition //updateCallback.onInserted(start, 1); updateCallback.Insert(start, source[start]); foreach (PostponedUpdate upd in postponedUpdates) { upd.currentPos += 1; } break; case FLAG_MOVED_CHANGED: case FLAG_MOVED_NOT_CHANGED: int pos = mNewItemStatuses[globalIndex + i] >> FLAG_OFFSET; PostponedUpdate update = RemovePostponedUpdate(postponedUpdates, pos, true); // the item was moved from that position //noinspection ConstantConditions //updateCallback.onMoved(update.currentPos, start); updateCallback.RemoveAt(update.currentPos); updateCallback.Insert(start, source[start]); //if (status == FLAG_MOVED_CHANGED) //{ // // also dispatch a change // updateCallback.onChanged(start, 1, // mCallback.getChangePayload(pos, globalIndex + i)); //} break; case FLAG_IGNORE: // ignoring this postponedUpdates.Add(new PostponedUpdate(globalIndex + i, start, false)); break; default: throw new Exception( "unknown flag for pos " + (globalIndex + i) + " " + status); } } }