Search in sources :

Example 11 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenFLexAppearanceIsUsed_shouldFlexboxLayoutManagerBeUsed.

@Test
public void whenFLexAppearanceIsUsed_shouldFlexboxLayoutManagerBeUsed() {
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, null, new ArrayList<>(), null, null, null, 0, 1, false, mock(MediaUtils.class));
    initRecyclerView(adapter, true);
    assertThat(recyclerView.getLayoutManager().getClass().getName(), equalTo(FlexboxLayoutManager.class.getName()));
}
Also used : MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Example 12 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class ChoicesRecyclerViewTest method whenNonFLexAppearanceIsUsedWithMoreThanOneColumn_shouldNotDividersBeAdded.

@Test
public void whenNonFLexAppearanceIsUsedWithMoreThanOneColumn_shouldNotDividersBeAdded() {
    List<SelectChoice> items = getTestChoices();
    setUpFormEntryPrompt(items, "");
    SelectOneListAdapter adapter = new SelectOneListAdapter(null, null, activityController.get(), items, formEntryPrompt, null, null, 0, 2, false, mock(MediaUtils.class));
    initRecyclerView(adapter, false);
    assertThat(recyclerView.getItemDecorationCount(), is(0));
}
Also used : SelectChoice(org.javarosa.core.model.SelectChoice) MediaUtils(org.odk.collect.android.utilities.MediaUtils) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) Test(org.junit.Test)

Example 13 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class SelectOneWidget method setUpAdapter.

@Override
protected AbstractSelectListAdapter setUpAdapter() {
    int numColumns = Appearances.getNumberOfColumns(getFormEntryPrompt(), screenUtils);
    boolean noButtonsMode = Appearances.isCompactAppearance(getFormEntryPrompt()) || Appearances.isNoButtonsAppearance(getFormEntryPrompt());
    recyclerViewAdapter = new SelectOneListAdapter(getSelectedValue(), this, getContext(), items, getFormEntryPrompt(), getReferenceManager(), getAudioHelper(), getPlayColor(getFormEntryPrompt(), themeUtils), numColumns, noButtonsMode, mediaUtils);
    return recyclerViewAdapter;
}
Also used : SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter) SuppressLint(android.annotation.SuppressLint)

Example 14 with SelectOneListAdapter

use of org.odk.collect.android.adapters.SelectOneListAdapter in project collect by opendatakit.

the class SelectOneWidget method setChoiceSelected.

@Override
public void setChoiceSelected(int choiceIndex, boolean isSelected) {
    RadioButton button = new RadioButton(getContext());
    button.setTag(choiceIndex);
    button.setChecked(isSelected);
    ((SelectOneListAdapter) recyclerViewAdapter).onCheckedChanged(button, isSelected);
}
Also used : RadioButton(android.widget.RadioButton) SelectOneListAdapter(org.odk.collect.android.adapters.SelectOneListAdapter)

Aggregations

SelectOneListAdapter (org.odk.collect.android.adapters.SelectOneListAdapter)14 Test (org.junit.Test)12 MediaUtils (org.odk.collect.android.utilities.MediaUtils)11 SelectChoice (org.javarosa.core.model.SelectChoice)10 SelectItemClickListener (org.odk.collect.android.listeners.SelectItemClickListener)5 SuppressLint (android.annotation.SuppressLint)1 RadioButton (android.widget.RadioButton)1 AudioHelper (org.odk.collect.android.audio.AudioHelper)1