Search in sources :

Example 1 with ScreenContext

use of org.odk.collect.android.utilities.ScreenContext in project collect by opendatakit.

the class AudioVideoImageTextLabel method setupAudioButton.

private void setupAudioButton(String audioURI, AudioHelper audioHelper) {
    binding.audioButton.setVisibility(VISIBLE);
    binding.mediaButtons.setVisibility(VISIBLE);
    ScreenContext activity = getScreenContext();
    String clipID = getTag() != null ? getTag().toString() : "";
    LiveData<Boolean> isPlayingLiveData = audioHelper.setAudio(binding.audioButton, new Clip(clipID, audioURI));
    originalTextColor = textLabel.getTextColors().getDefaultColor();
    isPlayingLiveData.observe(activity.getViewLifecycle(), isPlaying -> {
        if (isPlaying) {
            textLabel.setTextColor(playTextColor);
        } else {
            textLabel.setTextColor(originalTextColor);
            // then set the text to our original (brings back any html formatting)
            textLabel.setText(questionText);
        }
    });
}
Also used : Clip(org.odk.collect.audioclips.Clip) ScreenContext(org.odk.collect.android.utilities.ScreenContext)

Aggregations

ScreenContext (org.odk.collect.android.utilities.ScreenContext)1 Clip (org.odk.collect.audioclips.Clip)1