use of android.text.style.UnderlineSpan in project MyDiary by erttyy8821.
the class NoEntriesDialogFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
this.getDialog().setCanceledOnTouchOutside(true);
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
View rootView = inflater.inflate(R.layout.dialog_fragment_no_entries, container);
TV_no_entries_create = (TextView) rootView.findViewById(R.id.TV_no_entries_create);
TV_no_entries_create.setOnClickListener(this);
SpannableString content = new SpannableString(TV_no_entries_create.getText());
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
TV_no_entries_create.setText(content);
TV_no_entries_create.setTextColor(ThemeManager.getInstance().getThemeMainColor(getActivity()));
return rootView;
}
use of android.text.style.UnderlineSpan in project ExoPlayer by google.
the class WebvttCueParserTest method testParseStrictValidClassesAndTrailingTokens.
public void testParseStrictValidClassesAndTrailingTokens() throws Exception {
Spanned text = parseCueText("<v.first.loud Esme>" + "This <u.style1.style2 some stuff>is</u> text with <b.foo><i.bar>html</i></b> tags");
assertEquals("This is text with html tags", text.toString());
UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
assertEquals(1, underlineSpans.length);
assertEquals(2, styleSpans.length);
assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
assertEquals(Typeface.BOLD, styleSpans[1].getStyle());
assertEquals(5, text.getSpanStart(underlineSpans[0]));
assertEquals(7, text.getSpanEnd(underlineSpans[0]));
assertEquals(18, text.getSpanStart(styleSpans[0]));
assertEquals(18, text.getSpanStart(styleSpans[1]));
assertEquals(22, text.getSpanEnd(styleSpans[0]));
assertEquals(22, text.getSpanEnd(styleSpans[1]));
}
use of android.text.style.UnderlineSpan in project ExoPlayer by google.
the class WebvttCueParserTest method testParseWellFormedUnclosedEndAtCueEnd.
public void testParseWellFormedUnclosedEndAtCueEnd() throws Exception {
Spanned text = parseCueText("An <u some trailing stuff>unclosed u tag with " + "<i>italic</i> inside");
assertEquals("An unclosed u tag with italic inside", text.toString());
UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
assertEquals(1, underlineSpans.length);
assertEquals(1, styleSpans.length);
assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
assertEquals(3, text.getSpanStart(underlineSpans[0]));
assertEquals(23, text.getSpanStart(styleSpans[0]));
assertEquals(29, text.getSpanEnd(styleSpans[0]));
assertEquals(36, text.getSpanEnd(underlineSpans[0]));
}
use of android.text.style.UnderlineSpan in project ExoPlayer by google.
the class WebvttCueParserTest method testParseMalformedNestedElements.
public void testParseMalformedNestedElements() throws Exception {
Spanned text = parseCueText("<b><u>An unclosed u tag with <i>italic</u> inside</i></b>");
assertEquals("An unclosed u tag with italic inside", text.toString());
UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
assertEquals(1, underlineSpans.length);
assertEquals(2, styleSpans.length);
// all tags applied until matching start tag found
assertEquals(0, text.getSpanStart(underlineSpans[0]));
assertEquals(29, text.getSpanEnd(underlineSpans[0]));
if (styleSpans[0].getStyle() == Typeface.BOLD) {
assertEquals(0, text.getSpanStart(styleSpans[0]));
assertEquals(23, text.getSpanStart(styleSpans[1]));
assertEquals(29, text.getSpanEnd(styleSpans[1]));
assertEquals(36, text.getSpanEnd(styleSpans[0]));
} else {
assertEquals(0, text.getSpanStart(styleSpans[1]));
assertEquals(23, text.getSpanStart(styleSpans[0]));
assertEquals(29, text.getSpanEnd(styleSpans[0]));
assertEquals(36, text.getSpanEnd(styleSpans[1]));
}
}
use of android.text.style.UnderlineSpan in project ExoPlayer by google.
the class WebvttCueParserTest method testParseWellFormedUnclosedEndAtParent.
public void testParseWellFormedUnclosedEndAtParent() throws Exception {
Spanned text = parseCueText("An unclosed u tag with <i><u>underline and italic</i> inside");
assertEquals("An unclosed u tag with underline and italic inside", text.toString());
UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
assertEquals(1, underlineSpans.length);
assertEquals(1, styleSpans.length);
assertEquals(23, text.getSpanStart(underlineSpans[0]));
assertEquals(23, text.getSpanStart(styleSpans[0]));
assertEquals(43, text.getSpanEnd(underlineSpans[0]));
assertEquals(43, text.getSpanEnd(styleSpans[0]));
assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
}
Aggregations