use of com.ichi2.anki.noteeditor.FieldState.FieldChangeType in project AnkiChinaAndroid by ankichinateam.
the class NoteEditor method setNote.
/**
* Handles setting the current note (non-null afterwards) and rebuilding the UI based on this note
*/
private void setNote(Note note, @NonNull FieldChangeType changeType) {
if (note == null || mAddNote) {
Model model = getCol().getModels().current();
mEditorNote = new Note(getCol(), model);
} else {
mEditorNote = note;
}
if (mSelectedTags == null) {
mSelectedTags = mEditorNote.getTags();
}
// nb: setOnItemSelectedListener and populateEditFields need to occur after this
setNoteTypePosition();
updateDeckPosition();
updateTags();
updateCards(mEditorNote.model());
updateToolbar();
populateEditFields(changeType, false);
}
use of com.ichi2.anki.noteeditor.FieldState.FieldChangeType in project AnkiChinaAndroid by ankichinateam.
the class FieldState method loadFieldEditLines.
@NonNull
public List<FieldEditLine> loadFieldEditLines(FieldChangeType type) {
List<FieldEditLine> fieldEditLines;
if (type.mType == Type.INIT && mSavedFieldData != null) {
fieldEditLines = recreateFieldsFromState();
mSavedFieldData = null;
} else {
fieldEditLines = createFields(type);
}
for (FieldEditLine l : fieldEditLines) {
l.setId(ViewCompat.generateViewId());
}
if (type.mType == Type.CLEAR_KEEP_STICKY) {
// we use the UI values here as the model will post-processing steps (newline -> br).
String[] currentFieldStrings = mEditor.getCurrentFieldStrings();
JSONArray flds = mEditor.getCurrentFields();
for (int fldIdx = 0; fldIdx < flds.length(); fldIdx++) {
if (flds.getJSONObject(fldIdx).getBoolean("sticky")) {
fieldEditLines.get(fldIdx).setContent(currentFieldStrings[fldIdx], type.replaceNewlines);
}
}
}
if (type.mType == Type.CHANGE_FIELD_COUNT) {
String[] currentFieldStrings = mEditor.getCurrentFieldStrings();
for (int i = 0; i < Math.min(currentFieldStrings.length, fieldEditLines.size()); i++) {
fieldEditLines.get(i).setContent(currentFieldStrings[i], type.replaceNewlines);
}
}
return fieldEditLines;
}
use of com.ichi2.anki.noteeditor.FieldState.FieldChangeType in project Anki-Android by ankidroid.
the class NoteEditor method setNote.
/**
* Handles setting the current note (non-null afterwards) and rebuilding the UI based on this note
*/
private void setNote(Note note, @NonNull FieldChangeType changeType) {
if (note == null || mAddNote) {
Model model = getCol().getModels().current();
mEditorNote = new Note(getCol(), model);
} else {
mEditorNote = note;
}
if (mSelectedTags == null) {
mSelectedTags = mEditorNote.getTags();
}
// nb: setOnItemSelectedListener and populateEditFields need to occur after this
setNoteTypePosition();
setDid(note);
updateTags();
updateCards(mEditorNote.model());
updateToolbar();
populateEditFields(changeType, false);
updateFieldsFromStickyText();
}
Aggregations