private void undo(){
  lastWasUndo=true;
  if (pendingRemovalHeader != null) {
    list.add(pendingRemovalPosition - 1,pendingRemovalHeader);
    list.add(pendingRemovalPosition,pendingRemovalItem);
    notifyItemRangeInserted(pendingRemovalPosition - 1,2);
  }
 else {
    list.add(pendingRemovalPosition,pendingRemovalItem);
    notifyItemInserted(pendingRemovalPosition);
  }
  if (pendingRemovalSwipeDir == ItemTouchHelper.LEFT) {
    undoLeft(pendingRemovalItem.object);
  }
 else   if (pendingRemovalSwipeDir == ItemTouchHelper.RIGHT) {
    undoRight(pendingRemovalItem.object);
  }
}

private void undo ( ) { lastWasUndo = true ; if ( pendingRemovalHeader != null ) { list . add ( pendingRemovalPosition - 1 , pendingRemovalHeader ) ; list . add ( pendingRemovalPosition , pendingRemovalItem ) ; notifyItemRangeInserted ( pendingRemovalPosition - 1 , 2 ) ; } else { list . add ( pendingRemovalPosition , pendingRemovalItem ) ; notifyItemInserted ( pendingRemovalPosition ) ; } if ( pendingRemovalSwipeDir == ItemTouchHelper . LEFT ) { undoLeft ( pendingRemovalItem . object ) ; } else if ( pendingRemovalSwipeDir == ItemTouchHelper . RIGHT ) { undoRight ( pendingRemovalItem . object ) ; } }
called when user presses undo . call readd ( ) method to readd the item to the database . add the item back to the itemlist on it ' s old location and notify for changes .
