use of org.odk.collect.android.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenClickOneElementTwice_shouldThatElementBeUnselectedInSelectMultiButtonsMode.
@Test
public void whenClickOneElementTwice_shouldThatElementBeUnselectedInSelectMultiButtonsMode() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
SelectMultipleListAdapter adapter = new SelectMultipleListAdapter(new ArrayList<>(), listener, activityController.get(), items, formEntryPrompt, null, null, 0, 1, false, mock(MediaUtils.class));
initRecyclerView(adapter, false);
// Select AAA
clickChoice(0);
assertThat(isItemSelected(0), is(true));
assertThat(isItemSelected(1), is(false));
// Select AAA again
clickChoice(0);
assertThat(isItemSelected(0), is(false));
assertThat(isItemSelected(1), is(false));
}
use of org.odk.collect.android.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class ChoicesRecyclerViewTest method whenChoiceUnselectedInSelectMultiNoButtonsMode_shouldStopPlayingAudio.
@Test
public void whenChoiceUnselectedInSelectMultiNoButtonsMode_shouldStopPlayingAudio() {
List<SelectChoice> items = getTestChoices();
setUpFormEntryPrompt(items, "no-buttons");
SelectItemClickListener listener = mock(SelectItemClickListener.class);
List<Selection> selectedItems = new ArrayList<>();
selectedItems.add(items.get(0).selection());
SelectMultipleListAdapter adapter = spy(new SelectMultipleListAdapter(selectedItems, listener, activityController.get(), items, formEntryPrompt, null, audioHelper, 0, 1, true, mock(MediaUtils.class)));
initRecyclerView(adapter, false);
// Unselect AAA
clickChoice(0);
verify(adapter.getAudioHelper()).stop();
verify(adapter, never()).playAudio(any());
}
use of org.odk.collect.android.adapters.SelectMultipleListAdapter in project collect by opendatakit.
the class SelectMultiWidget method setUpAdapter.
@Override
protected AbstractSelectListAdapter setUpAdapter() {
int numColumns = Appearances.getNumberOfColumns(getFormEntryPrompt(), screenUtils);
boolean noButtonsMode = Appearances.isCompactAppearance(getFormEntryPrompt()) || Appearances.isNoButtonsAppearance(getFormEntryPrompt());
recyclerViewAdapter = new SelectMultipleListAdapter(getSelectedItems(), this, getContext(), items, getFormEntryPrompt(), getReferenceManager(), getAudioHelper(), getPlayColor(getFormEntryPrompt(), themeUtils), numColumns, noButtonsMode, mediaUtils);
return recyclerViewAdapter;
}
Aggregations