Search in sources :

Example 1 with ExternalSelectChoice

use of org.odk.collect.android.external.ExternalSelectChoice in project collect by opendatakit.

the class SelectWidget method createMediaLayout.

protected MediaLayout createMediaLayout(int index, TextView textView) {
    String audioURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), FormEntryCaption.TEXT_FORM_AUDIO);
    String imageURI;
    if (items.get(index) instanceof ExternalSelectChoice) {
        imageURI = ((ExternalSelectChoice) items.get(index)).getImage();
    } else {
        imageURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), FormEntryCaption.TEXT_FORM_IMAGE);
    }
    String videoURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), "video");
    String bigImageURI = getFormEntryPrompt().getSpecialFormSelectChoiceText(items.get(index), "big-image");
    MediaLayout mediaLayout = new MediaLayout(getContext(), getPlayer());
    mediaLayout.setAVT(getFormEntryPrompt().getIndex(), "." + Integer.toString(index), textView, audioURI, imageURI, videoURI, bigImageURI);
    mediaLayout.setAudioListener(this);
    mediaLayout.setPlayTextColor(getPlayColor());
    playList.add(mediaLayout);
    if (index != items.size() - 1) {
        ImageView divider = new ImageView(getContext());
        divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
        mediaLayout.addDivider(divider);
    }
    return mediaLayout;
}
Also used : ExternalSelectChoice(org.odk.collect.android.external.ExternalSelectChoice) MediaLayout(org.odk.collect.android.views.MediaLayout) ImageView(android.widget.ImageView)

Example 2 with ExternalSelectChoice

use of org.odk.collect.android.external.ExternalSelectChoice in project collect by opendatakit.

the class ExternalDataHandlerSearch method createDynamicSelectChoices.

protected ArrayList<SelectChoice> createDynamicSelectChoices(Cursor c, LinkedHashMap<String, String> selectColumnMap, String safeImageColumn) {
    List<String> columnsToExcludeFromLabels = new ArrayList<String>();
    if (safeImageColumn != null) {
        columnsToExcludeFromLabels.add(safeImageColumn);
    }
    ArrayList<SelectChoice> selectChoices = new ArrayList<SelectChoice>();
    if (c.getCount() > 0) {
        c.moveToPosition(-1);
        int index = 0;
        Set<String> uniqueValues = new HashSet<String>();
        while (c.moveToNext()) {
            // the value is always the first column
            String value = c.getString(0);
            if (!uniqueValues.contains(value)) {
                String label = buildLabel(c, selectColumnMap, columnsToExcludeFromLabels);
                ExternalSelectChoice selectChoice;
                if (label.trim().length() == 0) {
                    selectChoice = new ExternalSelectChoice(value, value, false);
                } else {
                    selectChoice = new ExternalSelectChoice(label, value, false);
                }
                selectChoice.setIndex(index);
                if (safeImageColumn != null && safeImageColumn.trim().length() > 0) {
                    String image = c.getString(c.getColumnIndex(safeImageColumn));
                    if (image != null && image.trim().length() > 0) {
                        selectChoice.setImage(ExternalDataUtil.JR_IMAGES_PREFIX + image);
                    }
                }
                selectChoices.add(selectChoice);
                index++;
                uniqueValues.add(value);
            }
        }
    }
    return selectChoices;
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) ExternalSelectChoice(org.odk.collect.android.external.ExternalSelectChoice) ArrayList(java.util.ArrayList) ExternalSelectChoice(org.odk.collect.android.external.ExternalSelectChoice) HashSet(java.util.HashSet)

Aggregations

ExternalSelectChoice (org.odk.collect.android.external.ExternalSelectChoice)2 ImageView (android.widget.ImageView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 SelectChoice (org.javarosa.core.model.SelectChoice)1 MediaLayout (org.odk.collect.android.views.MediaLayout)1