0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

NF: rename revertToProvidedState to revertNoteToProvidedState

That makes more clear that all siblings are reverted too
This commit is contained in:
Arthur Milchior 2021-04-09 09:21:52 +02:00 committed by Mike Hardy
parent f3a53cf5be
commit 30e3529f31
2 changed files with 10 additions and 4 deletions

View File

@ -508,7 +508,7 @@ public class CollectionTask<ProgressListener, ProgressBackground extends Progres
@Override
protected void actualTask(Collection col) {
// collect undo information
col.markUndo(revertToProvidedState(R.string.menu_bury_card, mCard));
col.markUndo(revertNoteToProvidedState(R.string.menu_bury_card, mCard));
// then bury
col.getSched().buryCards(new long[] {mCard.getId()});
}
@ -522,7 +522,7 @@ public class CollectionTask<ProgressListener, ProgressBackground extends Progres
@Override
protected void actualTask(Collection col) {
// collect undo information
col.markUndo(revertToProvidedState(R.string.menu_bury_note, mCard));
col.markUndo(revertNoteToProvidedState(R.string.menu_bury_note, mCard));
// then bury
col.getSched().buryNote(mCard.note().getId());
}
@ -560,7 +560,7 @@ public class CollectionTask<ProgressListener, ProgressBackground extends Progres
for (int i = 0; i < cards.size(); i++) {
cids[i] = cards.get(i).getId();
}
col.markUndo(revertToProvidedState(R.string.menu_suspend_note, mCard));
col.markUndo(revertNoteToProvidedState(R.string.menu_suspend_note, mCard));
// suspend note
col.getSched().suspendCards(cids);
}

View File

@ -35,7 +35,13 @@ public abstract class UndoAction {
* Returned positive integers are card id. Those ids is the card that was discarded and that may be sent back to the reviewer.*/
public abstract @Nullable Card undo(@NonNull Collection col);
public static @NonNull UndoAction revertToProvidedState (@StringRes int undoNameId, Card card){
/**
* Create an UndoAction that set back `card` and its siblings to the current states.
* @param undoNameId The id of the string representing an action that could be undone
* @param card the card currently in the reviewer
* @return An UndoAction which, if executed, put back the `card` in the state given here
*/
public static @NonNull UndoAction revertNoteToProvidedState(@StringRes int undoNameId, Card card){
Note note = card.note();
List<Card> cards = note.cards();
return new UndoAction(undoNameId) {