use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class AudioRecorderRecordingStatusHandlerTest method whenViewModelSessionUpdates_forDifferentSession_callsInProgressListenerWithNull.
@Test
public void whenViewModelSessionUpdates_forDifferentSession_callsInProgressListenerWithNull() {
FormEntryPrompt prompt = promptWithAnswer(null);
MutableLiveData<RecordingSession> sessionLiveData = new MutableLiveData<>(null);
when(audioRecorder.getCurrentSession()).thenReturn(sessionLiveData);
Consumer<Pair<Long, Integer>> listener = mock(Consumer.class);
provider.onRecordingStatusChange(prompt, listener);
verify(listener).accept(null);
sessionLiveData.setValue(new RecordingSession("something else", null, 1200L, 0, false));
verify(listener, times(2)).accept(null);
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class AudioRecordingControllerFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
zip4(formEntryViewModel.hasBackgroundRecording(), backgroundAudioViewModel.isBackgroundRecordingEnabled(), audioRecorder.getCurrentSession(), audioRecorder.failedToStart()).observe(getViewLifecycleOwner(), quad -> {
boolean hasBackgroundRecording = quad.first;
boolean isBackgroundRecordingEnabled = quad.second;
RecordingSession session = quad.third;
Consumable<Exception> failedToStart = quad.fourth;
update(hasBackgroundRecording, isBackgroundRecordingEnabled, session, failedToStart);
});
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
binding.pauseRecording.setVisibility(GONE);
}
binding.stopRecording.setOnClickListener(v -> audioRecorder.stop());
binding.help.setOnClickListener(v -> {
showIfNotShowing(BackgroundAudioHelpDialogFragment.class, getParentFragmentManager());
});
}
use of org.odk.collect.audiorecorder.recording.RecordingSession in project collect by opendatakit.
the class BackgroundAudioViewModel method handleRecordAction.
private void handleRecordAction(TreeReference treeReference, String quality) {
if (isBackgroundRecordingEnabled.getValue()) {
if (permissionsChecker.isPermissionGranted(Manifest.permission.RECORD_AUDIO)) {
if (isBackgroundRecording()) {
RecordingSession session = audioRecorder.getCurrentSession().getValue();
HashSet<TreeReference> treeReferences = (HashSet<TreeReference>) session.getId();
treeReferences.add(treeReference);
} else {
HashSet<TreeReference> treeReferences = new HashSet<>();
treeReferences.add(treeReference);
startBackgroundRecording(quality, treeReferences);
}
} else {
isPermissionRequired.setValue(true);
tempTreeReferences.add(treeReference);
if (tempQuality == null) {
tempQuality = quality;
}
}
}
}
Aggregations