Skip to content

Instantly share code, notes, and snippets.

@ataulm
Created March 29, 2018 16:43
Show Gist options
  • Save ataulm/36268a62b6a358dd8bd212c2f68bde83 to your computer and use it in GitHub Desktop.
Save ataulm/36268a62b6a358dd8bd212c2f68bde83 to your computer and use it in GitHub Desktop.
/**
* 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