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);
}
});
}
Aggregations