private void navigateNextPhrase(int phraseIndex) { if (phraseIndex >= getStudy().getPhrases().size()) { finishInterview(); } else { Bundle args = new Bundle(); args.putInt(ARG_PHRASE_INDEX, phraseIndex); Phrase phrase = getStudy().getPhrases().get(phraseIndex); if (!StringUtils.isNullOrEmpty(phrase.getAudio_url())) { Fragment fragment = new AudioPlaybackFragment(); fragment.setArguments(args); transactTo( getMainFragmentContainerId(), fragment, AudioPlaybackFragment.TAG + "_" + phraseIndex); } else if (phrase.getResponse_type() == Phrase.TYPE_AUDIO || phrase.getResponse_type() == Phrase.TYPE_TEXT_AUDIO) { Fragment fragment = new RecordingAudioFragment(); fragment.setArguments(args); transactTo( getMainFragmentContainerId(), fragment, RecordingAudioFragment.TAG + "_" + phraseIndex); } else { Fragment fragment = new RecordingTextFragment(); fragment.setArguments(args); transactTo( getMainFragmentContainerId(), fragment, RecordingTextFragment.TAG + "_" + phraseIndex); } } }
/** * called by audioPlaybackFragment once the user has heard the question. Go to * RecordingAudioFragment or RecordingTextFragment * * @param phraseIndex */ public void onAudioQuestionFinished(int phraseIndex) { Bundle args = new Bundle(); args.putInt(ARG_PHRASE_INDEX, phraseIndex); Phrase phrase = getStudy().getPhrases().get(phraseIndex); if (phrase.getResponse_type() == Phrase.TYPE_AUDIO || phrase.getResponse_type() == Phrase.TYPE_TEXT_AUDIO) { Fragment fragment = new RecordingAudioFragment(); fragment.setArguments(args); transactTo( getMainFragmentContainerId(), fragment, RecordingAudioFragment.TAG + "_" + phraseIndex); } else { Fragment fragment = new RecordingTextFragment(); fragment.setArguments(args); transactTo( getMainFragmentContainerId(), fragment, RecordingTextFragment.TAG + "_" + phraseIndex); } }