@Test public void whenChoicesHaveAudio_andNoButtonsMode_clickingChoice_playsAndStopsAudio() throws Exception { createMockReference(referenceManager, "file: String reference = createMockReference(referenceManager, "file: formEntryPrompt = new MockFormEntryPromptBuilder() .withIndex("i am index") .withAppearance(NO_BUTTONS) .withSelectChoices(asList( new SelectChoice("1", "1"), new SelectChoice("2", "2") )) .withSpecialFormSelectChoiceText(asList( new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, "file: new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, "file: )) .build(); GridWidget widget = getActualWidget(); widget.onItemClick(0); verify(audioHelper).play(new Clip("i am index 0", reference)); widget.onItemClick(0); verify(audioHelper).stop(); }
@Override protected void onItemClick(int index) { if (!selectedItems.contains(index)) { if (selectedItems.isEmpty()) { selectItem(index); } else { unselectItem(selectedItems.get(0)); selectItem(index); } } else { getAudioHelper().stop(); } if (quickAdvance && listener != null) { listener.advance(); } if (noButtonsMode) { SelectChoice item = items.get(index); Clip clip = getClip(getFormEntryPrompt(), item, getReferenceManager()); if (clip != null) { getAudioHelper().play(clip); } } widgetValueChanged(); }
GridWidget extends BaseGridWidget { @Override protected void onItemClick(int index) { if (!selectedItems.contains(index)) { if (selectedItems.isEmpty()) { selectItem(index); } else { unselectItem(selectedItems.get(0)); selectItem(index); } } else { getAudioHelper().stop(); } if (quickAdvance && listener != null) { listener.advance(); } if (noButtonsMode) { SelectChoice item = items.get(index); Clip clip = getClip(getFormEntryPrompt(), item, getReferenceManager()); if (clip != null) { getAudioHelper().play(clip); } } widgetValueChanged(); } }
GridWidget extends BaseGridWidget { @Override protected void onItemClick(int index) { if (!selectedItems.contains(index)) { if (selectedItems.isEmpty()) { selectItem(index); } else { unselectItem(selectedItems.get(0)); selectItem(index); } } else { getAudioHelper().stop(); } if (quickAdvance && listener != null) { listener.advance(); } if (noButtonsMode) { SelectChoice item = items.get(index); Clip clip = getClip(getFormEntryPrompt(), item, getReferenceManager()); if (clip != null) { getAudioHelper().play(clip); } } widgetValueChanged(); } GridWidget(Context context, QuestionDetails questionDetails, final boolean quickAdvance); }
GridWidget extends BaseGridWidget { @Override protected void onItemClick(int index) { if (!selectedItems.contains(index)) { if (selectedItems.isEmpty()) { selectItem(index); } else { unselectItem(selectedItems.get(0)); selectItem(index); } } else { getAudioHelper().stop(); } if (quickAdvance && listener != null) { listener.advance(); } if (noButtonsMode) { SelectChoice item = items.get(index); Clip clip = getClip(getFormEntryPrompt(), item, getReferenceManager()); if (clip != null) { getAudioHelper().play(clip); } } widgetValueChanged(); } GridWidget(Context context, QuestionDetails questionDetails, final boolean quickAdvance); @Override IAnswerData getAnswer(); @Override void setChoiceSelected(int choiceIndex, boolean isSelected); }
GridWidget extends BaseGridWidget { @Override protected void onItemClick(int index) { if (!selectedItems.contains(index)) { if (selectedItems.isEmpty()) { selectItem(index); } else { unselectItem(selectedItems.get(0)); selectItem(index); } } else { getAudioHelper().stop(); } if (quickAdvance && listener != null) { listener.advance(); } if (noButtonsMode) { SelectChoice item = items.get(index); Clip clip = getClip(getFormEntryPrompt(), item, getReferenceManager()); if (clip != null) { getAudioHelper().play(clip); } } widgetValueChanged(); } GridWidget(Context context, QuestionDetails questionDetails, final boolean quickAdvance); @Override IAnswerData getAnswer(); @Override void setChoiceSelected(int choiceIndex, boolean isSelected);  }