Search in sources :

Example 1 with NoSuchDeckException

use of com.ichi2.libanki.exception.NoSuchDeckException in project AnkiChinaAndroid by ankichinateam.

the class Collection method removeDeckOptionsFromDynamicDecks.

private ArrayList<String> removeDeckOptionsFromDynamicDecks(Runnable notifyProgress) {
    Timber.d("removeDeckOptionsFromDynamicDecks()");
    ArrayList<String> problems = new ArrayList<>();
    // #5708 - a dynamic deck should not have "Deck Options"
    notifyProgress.run();
    int fixCount = 0;
    for (long id : mDecks.allDynamicDeckIds()) {
        try {
            if (mDecks.hasDeckOptions(id)) {
                mDecks.removeDeckOptions(id);
                fixCount++;
            }
        } catch (NoSuchDeckException e) {
            Timber.e("Unable to find dynamic deck %d", id);
        }
    }
    if (fixCount > 0) {
        mDecks.save();
        problems.add(String.format(Locale.US, "%d dynamic deck(s) had deck options.", fixCount));
    }
    return problems;
}
Also used : ArrayList(java.util.ArrayList) NoSuchDeckException(com.ichi2.libanki.exception.NoSuchDeckException) SuppressLint(android.annotation.SuppressLint)

Example 2 with NoSuchDeckException

use of com.ichi2.libanki.exception.NoSuchDeckException in project Anki-Android by ankidroid.

the class Collection method removeDeckOptionsFromDynamicDecks.

private ArrayList<String> removeDeckOptionsFromDynamicDecks(Runnable notifyProgress) {
    Timber.d("removeDeckOptionsFromDynamicDecks()");
    ArrayList<String> problems = new ArrayList<>(1);
    // #5708 - a dynamic deck should not have "Deck Options"
    notifyProgress.run();
    int fixCount = 0;
    for (long id : mDecks.allDynamicDeckIds()) {
        try {
            if (hasDeckOptions(id)) {
                removeDeckOptions(id);
                fixCount++;
            }
        } catch (NoSuchDeckException e) {
            Timber.w(e, "Unable to find dynamic deck %d", id);
        }
    }
    if (fixCount > 0) {
        mDecks.save();
        problems.add(String.format(Locale.US, "%d dynamic deck(s) had deck options.", fixCount));
    }
    return problems;
}
Also used : ArrayList(java.util.ArrayList) NoSuchDeckException(com.ichi2.libanki.exception.NoSuchDeckException) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)2 NoSuchDeckException (com.ichi2.libanki.exception.NoSuchDeckException)2 ArrayList (java.util.ArrayList)2