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

Fixed Cloze text preview

(cherry picked from commit 658653ad28)
This commit is contained in:
Prateek Singh 2021-06-01 20:08:05 +05:30 committed by Mike Hardy
parent b232d0da19
commit f3ec41325a
No known key found for this signature in database
GPG Key ID: 2FB9315A0E38FF42

View File

@ -268,7 +268,11 @@ public class CardTemplatePreviewer extends AbstractFlashcardViewer {
return new PreviewerCard(col, cardListIndex);
}
/** Get a dummy card */
/**
* This method generates a note from a sample model, or fails if invalid. It does not currently have knowledge of field content
* A cloze uses the same model. Its content (not provided in params) determines validity of an ordinal
*/
protected @Nullable Card getDummyCard(Model model, int ordinal) {
Timber.d("getDummyCard() Creating dummy note for ordinal %s", ordinal);
if (model == null) {
@ -279,6 +283,11 @@ public class CardTemplatePreviewer extends AbstractFlashcardViewer {
for (int i = 0; i < fieldNames.size() && i < n.getFields().length; i++) {
n.setField(i, fieldNames.get(i));
}
if (model.isCloze()) {
ordinal = 0;
}
try {
JSONObject template = model.getJSONArray("tmpls").getJSONObject(ordinal);
return getCol().getNewLinkedCard(new PreviewerCard(getCol(), n), n, template, 1, 0L, false);