@Override
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, v, menuInfo);
   int selectedPosition = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
   Resources res = getResources();
   @SuppressWarnings("unused")
   MenuItem item;
   mSelectedCard = mDeck.cardFromId(Long.parseLong(mCards.get(selectedPosition).get("id")));
   if (mSelectedCard.isMarked()) {
     item =
         menu.add(
             Menu.NONE,
             CONTEXT_MENU_MARK,
             Menu.NONE,
             res.getString(R.string.card_browser_unmark_card));
     mIsMarked = true;
     Log.i(AnkiDroidApp.TAG, "Selected Card is currently marked");
   } else {
     item =
         menu.add(
             Menu.NONE,
             CONTEXT_MENU_MARK,
             Menu.NONE,
             res.getString(R.string.card_browser_mark_card));
     mIsMarked = false;
   }
   if (mSelectedCard.getSuspendedState()) {
     item =
         menu.add(
             Menu.NONE,
             CONTEXT_MENU_SUSPEND,
             Menu.NONE,
             res.getString(R.string.card_browser_unsuspend_card));
     mIsSuspended = true;
     Log.i(AnkiDroidApp.TAG, "Selected Card is currently suspended");
   } else {
     item =
         menu.add(
             Menu.NONE,
             CONTEXT_MENU_SUSPEND,
             Menu.NONE,
             res.getString(R.string.card_browser_suspend_card));
     mIsSuspended = false;
   }
   item =
       menu.add(
           Menu.NONE,
           CONTEXT_MENU_DELETE,
           Menu.NONE,
           res.getString(R.string.card_browser_delete_card));
   item =
       menu.add(
           Menu.NONE,
           CONTEXT_MENU_DETAILS,
           Menu.NONE,
           res.getString(R.string.card_browser_card_details));
   menu.setHeaderTitle(mCards.get(selectedPosition).get("question"));
 }
 @Override
 public void onPostExecute(DeckTask.TaskData result) {
   mUndoRedoCardId = result.getLong();
   String undoType = result.getString();
   if (undoType.equals(Deck.UNDO_TYPE_DELETE_CARD)) {
     int position = getPosition(mDeletedCards, mUndoRedoCardId);
     if (position != -1) {
       HashMap<String, String> data = new HashMap<String, String>();
       data.put("id", mDeletedCards.get(position).get("id"));
       data.put("question", mDeletedCards.get(position).get("question"));
       data.put("answer", mDeletedCards.get(position).get("answer"));
       data.put("marSus", mDeletedCards.get(position).get("marSus"));
       mAllCards.add(Integer.parseInt(mDeletedCards.get(position).get("allCardPos")), data);
       mDeletedCards.remove(position);
       updateCardsList();
     } else {
       deleteCard(Long.toString(mUndoRedoCardId), getPosition(mCards, mUndoRedoCardId));
     }
     mProgressDialog.dismiss();
   } else {
     mUndoRedoCard = mDeck.cardFromId(mUndoRedoCardId);
     if (undoType.equals(Deck.UNDO_TYPE_EDIT_CARD)) {
       mUndoRedoCard.fromDB(mUndoRedoCardId);
       int pos = getPosition(mAllCards, mUndoRedoCardId);
       updateCard(mUndoRedoCard, mAllCards, pos);
       pos = getPosition(mCards, mUndoRedoCardId);
       if (pos != -1) {
         updateCard(mUndoRedoCard, mCards, pos);
       }
       updateList();
       mProgressDialog.dismiss();
     } else if (undoType.equals(Deck.UNDO_TYPE_MARK_CARD)) {
       markCards(mUndoRedoCard.getFactId(), mUndoRedoCard.isMarked());
       mProgressDialog.dismiss();
     } else if (undoType.equals(Deck.UNDO_TYPE_SUSPEND_CARD)) {
       suspendCard(
           mUndoRedoCard,
           getPosition(mCards, mUndoRedoCardId),
           mUndoRedoCard.getSuspendedState());
       mProgressDialog.dismiss();
     } else {
       mUndoRedoDialogShowing = true;
       getCards();
     }
   }
 }
 private void updateCard(Card card, ArrayList<HashMap<String, String>> list, int position) {
   list.get(position).put("question", Utils.stripHTML(card.getQuestion().replace("<br>", "\n")));
   list.get(position).put("answer", Utils.stripHTML(card.getAnswer().replace("<br>", "\n")));
   for (long cardId : mDeck.getCardsFromFactId(card.getFactId())) {
     if (cardId != card.getId()) {
       int positionC = getPosition(mCards, cardId);
       int positionA = getPosition(mAllCards, cardId);
       Card c = mDeck.cardFromId(cardId);
       String question = Utils.stripHTML(c.getQuestion().replace("<br>", "\n"));
       String answer = Utils.stripHTML(c.getAnswer().replace("<br>", "\n"));
       if (positionC != -1) {
         mCards.get(positionC).put("question", question);
         mCards.get(positionC).put("answer", answer);
       }
       mAllCards.get(positionA).put("question", question);
       mAllCards.get(positionA).put("answer", answer);
     }
   }
 }