Esempio n. 1
0
  private void updateCardInList(Card card) {
    Note note = card.note();
    for (Card c : note.cards()) {
      int aPos = getPosition(mAllCards, c.getId());
      int pos = getPosition(mCards, c.getId());

      String sfld = note.getSFld();
      mAllCards.get(aPos).put("sfld", sfld);
      mCards.get(pos).put("sfld", sfld);

      if (mWholeCollection) {
        String deckName;
        try {
          deckName = mCol.getDecks().get(card.getDid()).getString("name");
        } catch (JSONException e) {
          throw new RuntimeException(e);
        }
        mAllCards.get(aPos).put("deck", deckName);
        mCards.get(pos).put("deck", deckName);
      }

      String flags =
          Integer.toString((c.getQueue() == -1 ? 1 : 0) + (note.hasTag("marked") ? 2 : 0));
      mAllCards.get(aPos).put("flags", flags);
      mCards.get(pos).put("flags", flags);
    }
    updateList();
  }
Esempio n. 2
0
 private void deleteNote(Card card) {
   ArrayList<Card> cards = card.note().cards();
   for (Card c : cards) {
     mCards.remove(getPosition(mCards, c.getId()));
     mAllCards.remove(getPosition(mAllCards, c.getId()));
   }
   updateList();
 }
 public void setCard(Card card) {
   mCurrentCard = card;
   Long cardId = 0l;
   if (card != null) {
     cardId = card.getId();
   }
   AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext())
       .edit()
       .putLong("lastWidgetCard", cardId)
       .commit();
 }
 @Override
 public void onDestroy() {
   // // TODO: this does not seem to be reliably called
   // String path = "";
   long cardId = 0l;
   if (mCol != null) {
     // path = mLoadedDeck.getDeckPath();
     // DeckManager.closeDeck(path, DeckManager.REQUESTING_ACTIVITY_BIGWIDGET);
     if (mCurrentCard != null) {
       cardId = mCurrentCard.getId();
     }
   }
   // PrefSettings.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext()).edit().putString("lastWidgetDeck",
   // path).commit();
   AnkiDroidApp.getSharedPrefs(AnkiDroidApp.getInstance().getBaseContext())
       .edit()
       .putLong("lastWidgetCard", cardId)
       .commit();
 }