Source:
public void notifyParentItemMoved(int fromParentPosition, int toParentPosition) { int fromWrapperIndex = getParentWrapperIndex(fromParentPosition); ParentWrapper fromParentWrapper = (ParentWrapper) mItemList.get(fromWrapperIndex); boolean isCollapsed = !fromParentWrapper.isExpanded(); boolean isExpandedNoChildren = !isCollapsed && (fromParentWrapper.getChildItemList().size() == 0); if (isCollapsed || isExpandedNoChildren) { int toWrapperIndex = getParentWrapperIndex(toParentPosition); ParentWrapper toParentWrapper = (ParentWrapper) mItemList.get(toWrapperIndex); mItemList.remove(fromWrapperIndex); int childOffset = 0; if (toParentWrapper.isExpanded()) { childOffset = toParentWrapper.getChildItemList().size(); } mItemList.add(toWrapperIndex + childOffset, fromParentWrapper); notifyItemMoved(fromWrapperIndex, toWrapperIndex + childOffset); } else { int sizeChanged = 0; int childListSize = fromParentWrapper.getChildItemList().size(); for (int i = 0; i < childListSize + 1; i++) { mItemList.remove(fromWrapperIndex); sizeChanged++; } notifyItemRangeRemoved(fromWrapperIndex, sizeChanged); int toWrapperIndex = getParentWrapperIndex(toParentPosition); ParentWrapper toParentWrapper = (ParentWrapper) mItemList.get(toWrapperIndex); int childOffset = 0; if (toParentWrapper.isExpanded()) { childOffset = toParentWrapper.getChildItemList().size(); } mItemList.add(toWrapperIndex + childOffset, fromParentWrapper); List<?> childItemList = fromParentWrapper.getChildItemList(); sizeChanged = childItemList.size() + 1; mItemList.addAll(toWrapperIndex + childOffset + 1, childItemList); notifyItemRangeInserted(toWrapperIndex + childOffset, sizeChanged); } }

Target:
public void notifyParentItemMoved(int fromParentPosition, int toParentPosition) { int fromWrapperIndex = getParentWrapperIndex(fromParentPosition); ParentWrapper fromParentWrapper = (ParentWrapper) mItemList.get(fromWrapperIndex); boolean isCollapsed = !fromParentWrapper.isExpanded(); boolean isExpandedNoChildren = !isCollapsed && (fromParentWrapper.getChildItemList().size() == 0); if (isCollapsed || isExpandedNoChildren) { int toWrapperIndex = getParentWrapperIndex(toParentPosition); ParentWrapper toParentWrapper = (ParentWrapper) mItemList.get(toWrapperIndex); mItemList.remove(fromWrapperIndex); int childOffset = 0; if (toParentWrapper.isExpanded()) { childOffset = toParentWrapper.getChildItemList().size(); } mItemList.add(toWrapperIndex + childOffset, fromParentWrapper); notifyItemMoved(fromWrapperIndex, toWrapperIndex + childOffset); } else { int sizeChanged = 0; int childListSize = fromParentWrapper.getChildItemList().size(); for (int i = 0; i < childListSize + 1; i++) { mItemList.remove(fromWrapperIndex); sizeChanged++; } notifyItemRangeRemoved(fromWrapperIndex, sizeChanged); int toWrapperIndex = getParentWrapperIndex(toParentPosition); int childOffset = 0; if (toWrapperIndex != -1) { ParentWrapper toParentWrapper = (ParentWrapper) mItemList.get(toWrapperIndex); if (toParentWrapper.isExpanded()) { childOffset = toParentWrapper.getChildItemList().size(); } } else { toWrapperIndex = mItemList.size(); } mItemList.add(toWrapperIndex + childOffset, fromParentWrapper); List<?> childItemList = fromParentWrapper.getChildItemList(); sizeChanged = childItemList.size() + 1; mItemList.addAll(toWrapperIndex + childOffset + 1, childItemList); notifyItemRangeInserted(toWrapperIndex + childOffset, sizeChanged); } }