Search in sources :

Example 6 with TextField

use of com.ichi2.anki.multimediacard.fields.TextField in project Anki-Android by Ramblurr.

the class EditFieldActivity method done.

protected void done() {
    mFieldController.onDone();
    Intent resultData = new Intent();
    boolean bChangeToText = false;
    if (mField.getType() == EFieldType.IMAGE) {
        if (mField.getImagePath() == null) {
            bChangeToText = true;
        }
        if (!bChangeToText) {
            File f = new File(mField.getImagePath());
            if (!f.exists()) {
                bChangeToText = true;
            }
        }
    } else if (mField.getType() == EFieldType.AUDIO) {
        if (mField.getAudioPath() == null) {
            bChangeToText = true;
        }
        if (!bChangeToText) {
            File f = new File(mField.getAudioPath());
            if (!f.exists()) {
                bChangeToText = true;
            }
        }
    }
    if (bChangeToText) {
        mField = new TextField();
        mField.setText(" - ");
    }
    resultData.putExtra(EXTRA_RESULT_FIELD, mField);
    resultData.putExtra(EXTRA_RESULT_FIELD_INDEX, mFieldIndex);
    setResult(RESULT_OK, resultData);
    finish();
}
Also used : TextField(com.ichi2.anki.multimediacard.fields.TextField) Intent(android.content.Intent) File(java.io.File)

Aggregations

TextField (com.ichi2.anki.multimediacard.fields.TextField)6 IMultimediaEditableNote (com.ichi2.anki.multimediacard.IMultimediaEditableNote)4 ImageField (com.ichi2.anki.multimediacard.fields.ImageField)3 MultimediaEditableNote (com.ichi2.anki.multimediacard.impl.MultimediaEditableNote)3 Intent (android.content.Intent)1 AudioField (com.ichi2.anki.multimediacard.fields.AudioField)1 IField (com.ichi2.anki.multimediacard.fields.IField)1 File (java.io.File)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1