Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Handles the splitting of {@link URLSpan}s into multiple
* {@link FeedbackFragment}s.
*
* @param fragment The fragment containing the spannable text to process.
* @param span The individual {@link StyleSpan} that represents the span
*/
private static void handleStyleSpan(FeedbackFragment fragment, StyleSpan span) {
final int style = span.getStyle();
final int earconId;
final float voicePitch;
switch (style) {
case Typeface.BOLD:
case Typeface.BOLD_ITALIC:
voicePitch = PITCH_CHANGE_BOLD;
earconId = R.raw.bold;
break;
case Typeface.ITALIC:
voicePitch = PITCH_CHANGE_ITALIC;
earconId = R.raw.italic;
break;
default:
return;
}
final Bundle speechParams = new Bundle(Bundle.EMPTY);
speechParams.putFloat(SpeechController.SpeechParam.PITCH, voicePitch);
fragment.setSpeechParams(speechParams);
fragment.addEarcon(earconId);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment