Search in sources :

Example 1 with ComponentActivity

use of androidx.activity.ComponentActivity in project collect by opendatakit.

the class InternalRecordingRequesterTest method setup.

@Before
public void setup() {
    ComponentActivity activity = Robolectric.buildActivity(ComponentActivity.class).get();
    when(audioRecorder.getCurrentSession()).thenReturn(new MutableLiveData<>(null));
    requester = new InternalRecordingRequester(activity, audioRecorder, permissionsProvider, mock(FormEntryViewModel.class));
    permissionsProvider.setPermissionGranted(true);
}
Also used : ComponentActivity(androidx.activity.ComponentActivity) Before(org.junit.Before)

Example 2 with ComponentActivity

use of androidx.activity.ComponentActivity in project collect by opendatakit.

the class BaseSelectListWidget method setUpSearchBox.

private void setUpSearchBox() {
    ComponentActivity activity = (ComponentActivity) getContext();
    SearchQueryViewModel searchQueryViewModel = new ViewModelProvider(activity).get(SearchQueryViewModel.class);
    binding.choicesSearchBox.setVisibility(View.VISIBLE);
    binding.choicesSearchBox.setTextSize(TypedValue.COMPLEX_UNIT_DIP, getAnswerFontSize());
    binding.choicesSearchBox.addTextChangedListener(new TextWatcher() {

        private String oldText = "";

        @Override
        public void afterTextChanged(Editable s) {
            if (!s.toString().equals(oldText)) {
                recyclerViewAdapter.getFilter().filter(s.toString());
                searchQueryViewModel.setQuery(getFormEntryPrompt().getIndex().toString(), s.toString());
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            oldText = s.toString();
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
    });
    binding.choicesSearchBox.setText(searchQueryViewModel.getQuery(getFormEntryPrompt().getIndex().toString()));
}
Also used : ComponentActivity(androidx.activity.ComponentActivity) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) SearchQueryViewModel(org.odk.collect.android.widgets.utilities.SearchQueryViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

ComponentActivity (androidx.activity.ComponentActivity)2 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 Before (org.junit.Before)1 SearchQueryViewModel (org.odk.collect.android.widgets.utilities.SearchQueryViewModel)1