android.text.style.UnderlineSpan Java Examples
The following examples show how to use
android.text.style.UnderlineSpan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AboutFragment.java From easyweather with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment getActivity().setTheme(R.style.DayTheme); if (MyApplication.nightMode2()) { initNightView(R.layout.night_mode_overlay); } View view = inflater.inflate(R.layout.fragment_about, container, false); TextView tv = (TextView) view.findViewById(R.id.link); String textStr = "https://github.com/byhieg/easyweather"; tv.setAutoLinkMask(Linkify.WEB_URLS); tv.setText(textStr); Spannable s = (Spannable) tv.getText(); s.setSpan(new UnderlineSpan() { @Override public void updateDrawState(TextPaint ds) { ds.setColor(ds.linkColor); ds.setUnderlineText(false); } }, 0, textStr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return view; }
Example #2
Source File: ScleraLinkView.java From arcusandroid with Apache License 2.0 | 6 votes |
@Override public void setText(CharSequence text, BufferType type) { if (!isInEditMode()) { // Normal use case. super.setText(text, type); } else { int length; if (text == null) { length = 0; } else { length = text.length(); } SpannableString spannableString = new SpannableString(text); spannableString.setSpan(new UnderlineSpan(), 0, length, 0); super.setText(spannableString, BufferType.SPANNABLE); } }
Example #3
Source File: Tx3gDecoder.java From MediaSDK with Apache License 2.0 | 6 votes |
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace, int defaultFontFace, int start, int end, int spanPriority) { if (fontFace != defaultFontFace) { final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority; boolean isBold = (fontFace & FONT_FACE_BOLD) != 0; boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0; if (isBold) { if (isItalic) { cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags); } else { cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags); } } else if (isItalic) { cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags); } boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0; if (isUnderlined) { cueText.setSpan(new UnderlineSpan(), start, end, flags); } if (!isUnderlined && !isBold && !isItalic) { cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags); } } }
Example #4
Source File: UndoRedoSupportEditText.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void undo() { EditItem edit = mEditHistory.getPrevious(); if (edit == null) { return; } Editable editable = mTextView.getEditableText(); int start = edit.start; int end = start + (edit.after != null ? edit.after.length() : 0); mIsUndoOrRedo = true; editable.replace(start, end, edit.before); mIsUndoOrRedo = false; for (Object o : editable.getSpans(0, editable.length(), UnderlineSpan.class)) { editable.removeSpan(o); } Selection.setSelection(editable, edit.before == null ? start : (start + edit.before.length())); }
Example #5
Source File: UndoRedoSupportEditText.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void redo() { EditItem edit = mEditHistory.getNext(); if (edit == null) { return; } Editable text = mTextView.getEditableText(); int start = edit.start; int end = start + (edit.before != null ? edit.before.length() : 0); mIsUndoOrRedo = true; text.replace(start, end, edit.after); mIsUndoOrRedo = false; // This will get rid of underlines inserted when editor tries to come // up with a suggestion. for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) { text.removeSpan(o); } Selection.setSelection(text, edit.after == null ? start : (start + edit.after.length())); }
Example #6
Source File: UndoRedoHelper.java From timecat with Apache License 2.0 | 6 votes |
/** * Perform undo. */ public void undo() { EditItem edit = mEditHistory.getPrevious(); if (edit == null) { return; } Editable text = mTextView.getEditableText(); int start = edit.mmStart; int end = start + (edit.mmAfter != null ? edit.mmAfter.length() : 0); mIsUndoOrRedo = true; text.replace(start, end, edit.mmBefore); mIsUndoOrRedo = false; // This will get rid of underlines inserted when editor tries to come // up with a suggestion. for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) { text.removeSpan(o); } Selection.setSelection(text, edit.mmBefore == null ? start : (start + edit.mmBefore.length())); }
Example #7
Source File: UndoRedoHelper.java From timecat with Apache License 2.0 | 6 votes |
/** * Perform redo. */ public void redo() { EditItem edit = mEditHistory.getNext(); if (edit == null) { return; } Editable text = mTextView.getEditableText(); int start = edit.mmStart; int end = start + (edit.mmBefore != null ? edit.mmBefore.length() : 0); mIsUndoOrRedo = true; text.replace(start, end, edit.mmAfter); mIsUndoOrRedo = false; // This will get rid of underlines inserted when editor tries to come // up with a suggestion. for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) { text.removeSpan(o); } Selection.setSelection(text, edit.mmAfter == null ? start : (start + edit.mmAfter.length())); }
Example #8
Source File: UndoRedoHelper.java From mua with MIT License | 6 votes |
/** * Perform undo. */ public void undo() { EditItem edit = mEditHistory.getPrevious(); if (edit == null) { return; } Editable text = mTextView.getEditableText(); int start = edit.mmStart; int end = start + (edit.mmAfter != null ? edit.mmAfter.length() : 0); mIsUndoOrRedo = true; text.replace(start, end, edit.mmBefore); mIsUndoOrRedo = false; // This will get rid of underlines inserted when editor tries to come // up with a suggestion. for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) { text.removeSpan(o); } Selection.setSelection(text, edit.mmBefore == null ? start : (start + edit.mmBefore.length())); }
Example #9
Source File: UndoRedoHelper.java From mua with MIT License | 6 votes |
/** * Perform redo. */ public void redo() { EditItem edit = mEditHistory.getNext(); if (edit == null) { return; } Editable text = mTextView.getEditableText(); int start = edit.mmStart; int end = start + (edit.mmBefore != null ? edit.mmBefore.length() : 0); mIsUndoOrRedo = true; text.replace(start, end, edit.mmAfter); mIsUndoOrRedo = false; // This will get rid of underlines inserted when editor tries to come // up with a suggestion. for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) { text.removeSpan(o); } Selection.setSelection(text, edit.mmAfter == null ? start : (start + edit.mmAfter.length())); }
Example #10
Source File: Tx3gDecoder.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace, int defaultFontFace, int start, int end, int spanPriority) { if (fontFace != defaultFontFace) { final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority; boolean isBold = (fontFace & FONT_FACE_BOLD) != 0; boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0; if (isBold) { if (isItalic) { cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags); } else { cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags); } } else if (isItalic) { cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags); } boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0; if (isUnderlined) { cueText.setSpan(new UnderlineSpan(), start, end, flags); } if (!isUnderlined && !isBold && !isItalic) { cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags); } } }
Example #11
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineUnderlineApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); Spanned text = (Spanned) textView.getText(); UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class); StrikethroughSpan[] strikeThroughSpans = text.getSpans(0, text.length(), StrikethroughSpan.class); assertThat(underlineSpan instanceof UnderlineSpan).isTrue(); assertThat(strikeThroughSpans).hasSize(0); }
Example #12
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); TextView textView = (TextView) rootView.getChildAt(0); Spanned text = (Spanned) textView.getText(); UnderlineSpan[] underlineSpans = text.getSpans(0, text.length(), UnderlineSpan.class); StrikethroughSpan strikeThroughSpan = getSingleSpan(textView, StrikethroughSpan.class); assertThat(underlineSpans).hasSize(0); assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue(); }
Example #13
Source File: ReactTextTest.java From react-native-GPay with MIT License | 6 votes |
@Test public void testTextDecorationLineUnderlineLineThroughApplied() { UIManagerModule uiManager = getUIManagerModule(); ReactRootView rootView = createText( uiManager, JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"), JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); UnderlineSpan underlineSpan = getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class); StrikethroughSpan strikeThroughSpan = getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class); assertThat(underlineSpan instanceof UnderlineSpan).isTrue(); assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue(); }
Example #14
Source File: UnderlineHandler.java From Markwon with Apache License 2.0 | 6 votes |
@Override public void handle( @NonNull MarkwonVisitor visitor, @NonNull MarkwonHtmlRenderer renderer, @NonNull HtmlTag tag) { // as parser doesn't treat U tag as an inline one, // thus doesn't allow children, we must visit them first if (tag.isBlock()) { visitChildren(visitor, renderer, tag.getAsBlock()); } SpannableBuilder.setSpans( visitor.builder(), new UnderlineSpan(), tag.start(), tag.end() ); }
Example #15
Source File: Cea608Decoder.java From K-Sonic with MIT License | 5 votes |
public void setUnderline(boolean enabled) { if (enabled) { underlineStartPosition = captionStringBuilder.length(); } else if (underlineStartPosition != POSITION_UNSET) { // underline spans won't overlap, so it's safe to modify the builder directly with them captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); underlineStartPosition = POSITION_UNSET; } }
Example #16
Source File: Cea708Decoder.java From K-Sonic with MIT License | 5 votes |
public SpannableString buildSpannableString() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(captionStringBuilder); int length = spannableStringBuilder.length(); if (length > 0) { if (italicsStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (underlineStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (foregroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new ForegroundColorSpan(foregroundColor), foregroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (backgroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), backgroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } return new SpannableString(spannableStringBuilder); }
Example #17
Source File: Cea608Decoder.java From K-Sonic with MIT License | 5 votes |
public SpannableString buildSpannableString() { int length = captionStringBuilder.length(); // preamble styles apply to the entire cue for (int i = 0; i < preambleStyles.size(); i++) { captionStringBuilder.setSpan(preambleStyles.get(i), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } // midrow styles only apply to part of the cue, and after preamble styles for (int i = 0; i < midrowStyles.size(); i++) { CueStyle cueStyle = midrowStyles.get(i); int end = (i < midrowStyles.size() - cueStyle.nextStyleIncrement) ? midrowStyles.get(i + cueStyle.nextStyleIncrement).start : length; captionStringBuilder.setSpan(cueStyle.style, cueStyle.start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } // special case for midrow underlines that went to the end of the cue if (underlineStartPosition != POSITION_UNSET) { captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } return new SpannableString(captionStringBuilder); }
Example #18
Source File: ReadWriteAdvertisementSlotDialogFragment.java From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void shortenUrl(final String longUrl){ if(!Utils.API_KEY.equals(Utils.UTILS_API_KEY)) { new Thread(new Runnable() { @Override public void run() { try { Urlshortener.Builder builder = new Urlshortener.Builder(AndroidHttp.newCompatibleTransport(), AndroidJsonFactory.getDefaultInstance(), null) .setApplicationName(getString(R.string.app_name)); Urlshortener urlshortener = builder.build(); com.google.api.services.urlshortener.model.Url url = new Url(); url.setLongUrl(longUrl); Urlshortener.Url.Insert insertUrl = urlshortener.url().insert(url); insertUrl.setKey(Utils.API_KEY); url = insertUrl.execute(); final String newUrl = url.getId(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { final SpannableString urlAttachment = new SpannableString(newUrl); urlAttachment.setSpan(new UnderlineSpan(), 0, newUrl.length(), 0); mUrlShortenerContainer.setVisibility(View.VISIBLE); mUrl.setError(null); mUrlShortText.setText(urlAttachment.toString()); mIsUrlExpanded = false; mExpandedUrl = null; } }); } catch (IOException ex) { Log.v(Utils.TAG, ex.getMessage()); } } }).start(); } else { Toast.makeText(getActivity(), getString(R.string.api_key_error), Toast.LENGTH_LONG); } }
Example #19
Source File: Cea708Decoder.java From K-Sonic with MIT License | 5 votes |
public void setPenAttributes(int textTag, int offset, int penSize, boolean italicsToggle, boolean underlineToggle, int edgeType, int fontStyle) { // TODO: Add support for text tags. // TODO: Add support for other offsets. // TODO: Add support for other pen sizes. if (italicsStartPosition != C.POSITION_UNSET) { if (!italicsToggle) { captionStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); italicsStartPosition = C.POSITION_UNSET; } } else if (italicsToggle) { italicsStartPosition = captionStringBuilder.length(); } if (underlineStartPosition != C.POSITION_UNSET) { if (!underlineToggle) { captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); underlineStartPosition = C.POSITION_UNSET; } } else if (underlineToggle) { underlineStartPosition = captionStringBuilder.length(); } // TODO: Add support for edge types. // TODO: Add support for other font styles. }
Example #20
Source File: WXTextDomObject.java From weex-uikit with MIT License | 5 votes |
/** * Create a task list which contains {@link SetSpanOperation}. The task list will be executed * in other method. * @param end the end character of the text. * @return a task list which contains {@link SetSpanOperation}. */ private List<SetSpanOperation> createSetSpanOperation(int end, int spanFlag) { List<SetSpanOperation> ops = new LinkedList<>(); int start = 0; if (end >= start) { if (mTextDecoration == WXTextDecoration.UNDERLINE) { ops.add(new SetSpanOperation(start, end, new UnderlineSpan(), spanFlag)); } if (mTextDecoration == WXTextDecoration.LINETHROUGH) { ops.add(new SetSpanOperation(start, end, new StrikethroughSpan(), spanFlag)); } if (mIsColorSet) { ops.add(new SetSpanOperation(start, end, new ForegroundColorSpan(mColor), spanFlag)); } if (mFontSize != UNSET) { ops.add(new SetSpanOperation(start, end, new AbsoluteSizeSpan(mFontSize), spanFlag)); } if (mFontStyle != UNSET || mFontWeight != UNSET || mFontFamily != null) { ops.add(new SetSpanOperation(start, end, new WXCustomStyleSpan(mFontStyle, mFontWeight, mFontFamily), spanFlag)); } ops.add(new SetSpanOperation(start, end, new AlignmentSpan.Standard(mAlignment), spanFlag)); if (mLineHeight != UNSET) { ops.add(new SetSpanOperation(start, end, new WXLineHeightSpan(mLineHeight), spanFlag)); } } return ops; }
Example #21
Source File: WebvttCueParser.java From MediaSDK with Apache License 2.0 | 5 votes |
private static void applySpansForTag( @Nullable String cueId, StartTag startTag, SpannableStringBuilder text, List<WebvttCssStyle> styles, List<StyleMatch> scratchStyleMatches) { int start = startTag.position; int end = text.length(); switch(startTag.name) { case TAG_BOLD: text.setSpan(new StyleSpan(STYLE_BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case TAG_ITALIC: text.setSpan(new StyleSpan(STYLE_ITALIC), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case TAG_UNDERLINE: text.setSpan(new UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case TAG_CLASS: case TAG_LANG: case TAG_VOICE: case "": // Case of the "whole cue" virtual tag. break; default: return; } scratchStyleMatches.clear(); getApplicableStyles(styles, cueId, startTag, scratchStyleMatches); int styleMatchesCount = scratchStyleMatches.size(); for (int i = 0; i < styleMatchesCount; i++) { applyStyleToText(text, scratchStyleMatches.get(i).style, start, end); } }
Example #22
Source File: TextFormatBar.java From revolution-irc with GNU General Public License v3.0 | 5 votes |
public void updateFormattingAtCursor() { if (mEditText == null) return; Editable text = mEditText.getText(); int start = mEditText.getSelectionStart(); int end = mEditText.getSelectionEnd(); Object[] spans = text.getSpans(start, end, Object.class); mBoldButton.setSelected(false); mItalicButton.setSelected(false); mUnderlineButton.setSelected(false); int fgColor = -1; int bgColor = -1; for (Object span : spans) { if (!SpannableStringHelper.checkSpanInclude(text, span, start, end) || (text.getSpanFlags(span) & Spanned.SPAN_COMPOSING) != 0) continue; if (span instanceof StyleSpan) { int style = ((StyleSpan) span).getStyle(); if (style == Typeface.BOLD) mBoldButton.setSelected(true); else if (style == Typeface.ITALIC) mItalicButton.setSelected(true); } else if (span instanceof UnderlineSpan) { mUnderlineButton.setSelected(true); } else if (span instanceof ForegroundColorSpan) { fgColor = ((ForegroundColorSpan) span).getForegroundColor(); } else if (span instanceof BackgroundColorSpan) { bgColor = ((BackgroundColorSpan) span).getBackgroundColor(); } } ImageViewCompat.setImageTintList(mTextColorValue, fgColor != -1 ? ColorStateList.valueOf(fgColor) : mTextColorValueDefault); ImageViewCompat.setImageTintList(mFillColorValue, bgColor != -1 ? ColorStateList.valueOf(bgColor) : mFillColorValueDefault); }
Example #23
Source File: MarkdownListDocumentAdapter.java From ncalc with GNU General Public License v3.0 | 5 votes |
private CharSequence highlightQuery(String text) { if (query == null || query.isEmpty()) { return text; } SpannableString spannableString = new SpannableString(text); Pattern pattern = Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(spannableString); while (matcher.find()) { int start = matcher.start(); int end = matcher.end(); spannableString.setSpan(new UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } return spannableString; }
Example #24
Source File: Spans.java From spanner with Apache License 2.0 | 5 votes |
/** * @see UnderlineSpan#UnderlineSpan() */ public static Span underline() { return new Span(new SpanBuilder() { @Override public Object build() { return new UnderlineSpan(); } }); }
Example #25
Source File: MarkDownParser.java From RichEditor with Apache License 2.0 | 5 votes |
private String spanToMarkDown(List<Object> mSpans, String source, int start, int end) { if (mSpans == null || mSpans.size() == 0) { return source.substring(start, end); } String str = source.substring(start, end); for (Object obj : mSpans) { if (obj instanceof StyleSpan) { StyleSpan objSpan = (StyleSpan) obj; switch (objSpan.getStyle()) { case Typeface.BOLD: str = formater.formatBold(str); break; case Typeface.ITALIC: str = formater.formatItalics(str); break; } } else if (obj instanceof UnderlineSpan) { //markdown是不支持下划线的!!!,后期考虑注释掉 str = formater.formatUnderLine(str); } else if (obj instanceof StrikethroughSpan) { str = formater.formatCenterLine(str); } else if (obj instanceof URLSpanNoUnderline) { URLSpanNoUnderline url = (URLSpanNoUnderline) obj; str = formater.formatLink(str, url.getURL()); } } return str; }
Example #26
Source File: Cea708Decoder.java From MediaSDK with Apache License 2.0 | 5 votes |
public void setPenAttributes(int textTag, int offset, int penSize, boolean italicsToggle, boolean underlineToggle, int edgeType, int fontStyle) { // TODO: Add support for text tags. // TODO: Add support for other offsets. // TODO: Add support for other pen sizes. if (italicsStartPosition != C.POSITION_UNSET) { if (!italicsToggle) { captionStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); italicsStartPosition = C.POSITION_UNSET; } } else if (italicsToggle) { italicsStartPosition = captionStringBuilder.length(); } if (underlineStartPosition != C.POSITION_UNSET) { if (!underlineToggle) { captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); underlineStartPosition = C.POSITION_UNSET; } } else if (underlineToggle) { underlineStartPosition = captionStringBuilder.length(); } // TODO: Add support for edge types. // TODO: Add support for other font styles. }
Example #27
Source File: Cea708Decoder.java From MediaSDK with Apache License 2.0 | 5 votes |
public SpannableString buildSpannableString() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(captionStringBuilder); int length = spannableStringBuilder.length(); if (length > 0) { if (italicsStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (underlineStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (foregroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new ForegroundColorSpan(foregroundColor), foregroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (backgroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), backgroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } return new SpannableString(spannableStringBuilder); }
Example #28
Source File: Cea708Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public SpannableString buildSpannableString() { SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(captionStringBuilder); int length = spannableStringBuilder.length(); if (length > 0) { if (italicsStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (underlineStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (foregroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new ForegroundColorSpan(foregroundColor), foregroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (backgroundColorStartPosition != C.POSITION_UNSET) { spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), backgroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } return new SpannableString(spannableStringBuilder); }
Example #29
Source File: Cea708Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setPenAttributes(int textTag, int offset, int penSize, boolean italicsToggle, boolean underlineToggle, int edgeType, int fontStyle) { // TODO: Add support for text tags. // TODO: Add support for other offsets. // TODO: Add support for other pen sizes. if (italicsStartPosition != C.POSITION_UNSET) { if (!italicsToggle) { captionStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); italicsStartPosition = C.POSITION_UNSET; } } else if (italicsToggle) { italicsStartPosition = captionStringBuilder.length(); } if (underlineStartPosition != C.POSITION_UNSET) { if (!underlineToggle) { captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); underlineStartPosition = C.POSITION_UNSET; } } else if (underlineToggle) { underlineStartPosition = captionStringBuilder.length(); } // TODO: Add support for edge types. // TODO: Add support for other font styles. }
Example #30
Source File: ProjectSelectionDialogFragment.java From Android-nRF-Beacon-for-Eddystone with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void parseProjectsFromResponse(JSONObject jsonResponse){ try { mProjectList.clear(); mAdapterProjectsList.notifyDataSetChanged(); Project project; JSONObject tempJsonObj; mOkButton.setVisibility(View.VISIBLE); if(jsonResponse.has("projects")) { JSONArray jsonArr = jsonResponse.getJSONArray("projects"); mProjectsListView.setVisibility(View.VISIBLE); for (int i = 0; i < jsonArr.length(); i++) { tempJsonObj = jsonArr.getJSONObject(i); project = new Project(tempJsonObj.getString("name"), tempJsonObj.getString("projectId")); mProjectList.add(project); } mAdapterProjectsList.notifyDataSetChanged(); } else { mProjectsListView.setVisibility(View.GONE); SpannableString stringUrl = new SpannableString(Utils.DEVELOPER_CONSOLE_URL); stringUrl.setSpan(new UnderlineSpan(), 0, Utils.DEVELOPER_CONSOLE_URL.length(), 0); mProjectsSummary.setVisibility(View.VISIBLE); mProjectsSummary.setText(getString(R.string.no_projects_available)); } hideProgressDialog(); } catch (JSONException e) { e.printStackTrace(); } }