mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-20 20:03:05 +02:00
NF: Extract helper method from Decks
Only used once
This commit is contained in:
parent
b042b87853
commit
8cf130621b
@ -1715,8 +1715,8 @@ public class Collection implements CollectionGetter {
|
||||
int fixCount = 0;
|
||||
for (long id : mDecks.allDynamicDeckIds()) {
|
||||
try {
|
||||
if (mDecks.hasDeckOptions(id)) {
|
||||
mDecks.removeDeckOptions(id);
|
||||
if (hasDeckOptions(id)) {
|
||||
removeDeckOptions(id);
|
||||
fixCount++;
|
||||
}
|
||||
} catch (NoSuchDeckException e) {
|
||||
@ -1731,6 +1731,24 @@ public class Collection implements CollectionGetter {
|
||||
}
|
||||
|
||||
|
||||
private Deck getDeckOrFail(long deckId) throws NoSuchDeckException {
|
||||
Deck deck = getDecks().get(deckId, false);
|
||||
if (deck == null) {
|
||||
throw new NoSuchDeckException(deckId);
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
private boolean hasDeckOptions(long deckId) throws NoSuchDeckException {
|
||||
return getDeckOrFail(deckId).has("conf");
|
||||
}
|
||||
|
||||
|
||||
private void removeDeckOptions(long deckId) throws NoSuchDeckException {
|
||||
getDeckOrFail(deckId).remove("conf");
|
||||
}
|
||||
|
||||
|
||||
private ArrayList<String> removeDynamicPropertyFromNonDynamicDecks(Runnable notifyProgress) {
|
||||
Timber.d("removeDynamicPropertyFromNonDynamicDecks()");
|
||||
ArrayList<String> problems = new ArrayList<>(1);
|
||||
|
@ -28,7 +28,6 @@ import com.ichi2.anki.AnkiDroidApp;
|
||||
import com.ichi2.anki.exception.ConfirmModSchemaException;
|
||||
import com.ichi2.anki.exception.DeckRenameException;
|
||||
import com.ichi2.anki.exception.FilteredAncestor;
|
||||
import com.ichi2.libanki.exception.NoSuchDeckException;
|
||||
|
||||
import com.ichi2.utils.DeckComparator;
|
||||
import com.ichi2.utils.DeckNameComparator;
|
||||
@ -1293,23 +1292,6 @@ public class Decks {
|
||||
return validValues.toArray(new Long[0]);
|
||||
}
|
||||
|
||||
private Deck getDeckOrFail(long deckId) throws NoSuchDeckException {
|
||||
Deck deck = get(deckId, false);
|
||||
if (deck == null) {
|
||||
throw new NoSuchDeckException(deckId);
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
|
||||
public boolean hasDeckOptions(long deckId) throws NoSuchDeckException {
|
||||
return getDeckOrFail(deckId).has("conf");
|
||||
}
|
||||
|
||||
|
||||
public void removeDeckOptions(long deckId) throws NoSuchDeckException {
|
||||
getDeckOrFail(deckId).remove("conf");
|
||||
}
|
||||
|
||||
public static boolean isDynamic(Collection col, long deckId) {
|
||||
return Decks.isDynamic(col.getDecks().get(deckId));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user