use of com.ichi2.anki.multimediacard.IMultimediaEditableNote in project Anki-Android by Ramblurr.
the class MultimediaCardEditorActivity method createEditorUI.
/**
* Creates the UI for editor area inside EditorLayout
*
* @param note
*/
private void createEditorUI(IMultimediaEditableNote note) {
try {
if (mNote == null) {
finishCancel();
return;
} else {
for (int i = 0; i < mNote.getNumberOfFields(); ++i) {
IField f = mNote.getField(i);
if (f == null) {
finishCancel();
return;
}
}
}
LinearLayout linearLayout = mEditorLayout;
linearLayout.removeAllViews();
for (int i = 0; i < note.getNumberOfFields(); ++i) {
createNewViewer(linearLayout, note.getField(i), i);
}
mModelButton.setText(gtxt(R.string.multimedia_editor_activity_note_type) + " : " + mEditorNote.model().getString("name"));
mDeckButton.setText(gtxt(R.string.multimedia_editor_activity_deck) + " : " + mCol.getDecks().get(mCurrentDid).getString("name"));
} catch (JSONException e) {
Log.e("Multimedia Editor", e.getMessage());
return;
}
}
use of com.ichi2.anki.multimediacard.IMultimediaEditableNote in project Anki-Android by Ramblurr.
the class MockNoteFactory method makeNote.
public static IMultimediaEditableNote makeNote() {
MultimediaEditableNote note = new MultimediaEditableNote();
note.setNumFields(4);
TextField tf = new TextField();
tf.setText("world");
note.setField(0, tf);
TextField tf2 = new TextField();
tf2.setText("Welt");
note.setField(1, tf2);
TextField tf3 = new TextField();
tf3.setText("Übung");
note.setField(2, tf3);
ImageField imageField = new ImageField();
imageField.setImagePath("/mnt/sdcard/img/1.jpg");
note.setField(3, imageField);
return note;
}
use of com.ichi2.anki.multimediacard.IMultimediaEditableNote in project Anki-Android by Ramblurr.
the class NoteService method updateMultimediaNoteFromJsonNote.
public static void updateMultimediaNoteFromJsonNote(final Note editorNoteSrc, final IMultimediaEditableNote noteDst) {
if (noteDst instanceof MultimediaEditableNote) {
MultimediaEditableNote mmNote = (MultimediaEditableNote) noteDst;
String[] values = editorNoteSrc.getFields();
for (int i = 0; i < values.length; i++) {
String value = values[i];
IField field = null;
if (value.startsWith("<img")) {
field = new ImageField();
} else if (value.startsWith("[sound:")) {
field = new AudioField();
} else {
field = new TextField();
}
field.setFormattedString(value);
mmNote.setField(i, field);
}
mmNote.setModelId(editorNoteSrc.getMid());
// TODO: set current id of the note as well
}
}
use of com.ichi2.anki.multimediacard.IMultimediaEditableNote in project Anki-Android by Ramblurr.
the class NoteService method updateJsonNoteFromMultimediaNote.
/**
* Updates the JsonNote field values from MultimediaEditableNote When both notes are using the same Model, it updaes
* the destination field values with source values. If models are different it throws an Exception
*
* @param mNoteSrc
* @param mEditorNoteDst
*/
public static void updateJsonNoteFromMultimediaNote(final IMultimediaEditableNote noteSrc, final Note editorNoteDst) {
if (noteSrc instanceof MultimediaEditableNote) {
MultimediaEditableNote mmNote = (MultimediaEditableNote) noteSrc;
if (mmNote.getModelId() != editorNoteDst.getMid()) {
throw new RuntimeException("Source and Destination Note ID do not match.");
}
int totalFields = mmNote.getNumberOfFields();
for (int i = 0; i < totalFields; i++) {
editorNoteDst.values()[i] = mmNote.getField(i).getFormattedValue();
}
}
}
use of com.ichi2.anki.multimediacard.IMultimediaEditableNote in project Anki-Android by Ramblurr.
the class NoteFactory method createNote.
public static IMultimediaEditableNote createNote() {
MultimediaEditableNote note = new MultimediaEditableNote();
note.setNumFields(4);
TextField tf = new TextField();
tf.setText("world");
note.setField(0, tf);
TextField tf2 = new TextField();
tf2.setText("Welt");
note.setField(1, tf2);
TextField tf3 = new TextField();
tf3.setText("Übung");
note.setField(2, tf3);
ImageField imageField = new ImageField();
imageField.setImagePath("/mnt/sdcard/img/1.jpg");
note.setField(3, imageField);
return note;
}
Aggregations