Search in sources :

Example 36 with URLSpan

use of android.text.style.URLSpan in project XUtil by xuexiangjys.

the class SpanUtils method updateCharCharSequence.

private void updateCharCharSequence() {
    if (mText.length() == 0)
        return;
    int start = mBuilder.length();
    mBuilder.append(mText);
    int end = mBuilder.length();
    if (foregroundColor != COLOR_DEFAULT) {
        mBuilder.setSpan(new ForegroundColorSpan(foregroundColor), start, end, flag);
    }
    if (backgroundColor != COLOR_DEFAULT) {
        mBuilder.setSpan(new BackgroundColorSpan(backgroundColor), start, end, flag);
    }
    if (first != -1) {
        mBuilder.setSpan(new LeadingMarginSpan.Standard(first, rest), start, end, flag);
    }
    if (quoteColor != COLOR_DEFAULT) {
        mBuilder.setSpan(new CustomQuoteSpan(quoteColor, stripeWidth, quoteGapWidth), start, end, flag);
    }
    if (bulletColor != COLOR_DEFAULT) {
        mBuilder.setSpan(new CustomBulletSpan(bulletColor, bulletRadius, bulletGapWidth), start, end, flag);
    }
    if (iconMarginGapWidth != -1) {
        if (iconMarginBitmap != null) {
            mBuilder.setSpan(new CustomIconMarginSpan(iconMarginBitmap, iconMarginGapWidth, alignIconMargin), start, end, flag);
        } else if (iconMarginDrawable != null) {
            mBuilder.setSpan(new CustomIconMarginSpan(iconMarginDrawable, iconMarginGapWidth, alignIconMargin), start, end, flag);
        } else if (iconMarginUri != null) {
            mBuilder.setSpan(new CustomIconMarginSpan(iconMarginUri, iconMarginGapWidth, alignIconMargin), start, end, flag);
        } else if (iconMarginResourceId != -1) {
            mBuilder.setSpan(new CustomIconMarginSpan(iconMarginResourceId, iconMarginGapWidth, alignIconMargin), start, end, flag);
        }
    }
    if (fontSize != -1) {
        mBuilder.setSpan(new AbsoluteSizeSpan(fontSize, fontSizeIsDp), start, end, flag);
    }
    if (proportion != -1) {
        mBuilder.setSpan(new RelativeSizeSpan(proportion), start, end, flag);
    }
    if (xProportion != -1) {
        mBuilder.setSpan(new ScaleXSpan(xProportion), start, end, flag);
    }
    if (lineHeight != -1) {
        mBuilder.setSpan(new CustomLineHeightSpan(lineHeight, alignLine), start, end, flag);
    }
    if (isStrikethrough) {
        mBuilder.setSpan(new StrikethroughSpan(), start, end, flag);
    }
    if (isUnderline) {
        mBuilder.setSpan(new UnderlineSpan(), start, end, flag);
    }
    if (isSuperscript) {
        mBuilder.setSpan(new SuperscriptSpan(), start, end, flag);
    }
    if (isSubscript) {
        mBuilder.setSpan(new SubscriptSpan(), start, end, flag);
    }
    if (isBold) {
        mBuilder.setSpan(new StyleSpan(Typeface.BOLD), start, end, flag);
    }
    if (isItalic) {
        mBuilder.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flag);
    }
    if (isBoldItalic) {
        mBuilder.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flag);
    }
    if (fontFamily != null) {
        mBuilder.setSpan(new TypefaceSpan(fontFamily), start, end, flag);
    }
    if (typeface != null) {
        mBuilder.setSpan(new CustomTypefaceSpan(typeface), start, end, flag);
    }
    if (alignment != null) {
        mBuilder.setSpan(new AlignmentSpan.Standard(alignment), start, end, flag);
    }
    if (clickSpan != null) {
        mBuilder.setSpan(clickSpan, start, end, flag);
    }
    if (url != null) {
        mBuilder.setSpan(new URLSpan(url), start, end, flag);
    }
    if (blurRadius != -1) {
        mBuilder.setSpan(new MaskFilterSpan(new BlurMaskFilter(blurRadius, style)), start, end, flag);
    }
    if (shader != null) {
        mBuilder.setSpan(new ShaderSpan(shader), start, end, flag);
    }
    if (shadowRadius != -1) {
        mBuilder.setSpan(new ShadowSpan(shadowRadius, shadowDx, shadowDy, shadowColor), start, end, flag);
    }
    if (spans != null) {
        for (Object span : spans) {
            mBuilder.setSpan(span, start, end, flag);
        }
    }
}
Also used : AlignmentSpan(android.text.style.AlignmentSpan) SuperscriptSpan(android.text.style.SuperscriptSpan) ScaleXSpan(android.text.style.ScaleXSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) URLSpan(android.text.style.URLSpan) SubscriptSpan(android.text.style.SubscriptSpan) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) UnderlineSpan(android.text.style.UnderlineSpan) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan) MaskFilterSpan(android.text.style.MaskFilterSpan) StyleSpan(android.text.style.StyleSpan) LeadingMarginSpan(android.text.style.LeadingMarginSpan) BlurMaskFilter(android.graphics.BlurMaskFilter) BackgroundColorSpan(android.text.style.BackgroundColorSpan) StrikethroughSpan(android.text.style.StrikethroughSpan) TypefaceSpan(android.text.style.TypefaceSpan)

Example 37 with URLSpan

use of android.text.style.URLSpan in project android-aosp-mms by slvn.

the class ComposeMessageActivity method getSelectedUriFromMessageList.

private Uri getSelectedUriFromMessageList(ListView listView, int position) {
    // If the context menu was opened over a uri, get that uri.
    MessageListItem msglistItem = (MessageListItem) listView.getChildAt(position);
    if (msglistItem == null) {
        // cannot get corrent view when in touch mode.
        return null;
    }
    TextView textView;
    CharSequence text = null;
    int selStart = -1;
    int selEnd = -1;
    // check if message sender is selected
    textView = (TextView) msglistItem.findViewById(R.id.text_view);
    if (textView != null) {
        text = textView.getText();
        selStart = textView.getSelectionStart();
        selEnd = textView.getSelectionEnd();
    }
    // just being placed within the TextView.
    if (selStart != selEnd) {
        int min = Math.min(selStart, selEnd);
        int max = Math.max(selStart, selEnd);
        URLSpan[] urls = ((Spanned) text).getSpans(min, max, URLSpan.class);
        if (urls.length == 1) {
            return Uri.parse(urls[0].getURL());
        }
    }
    // no uri was selected
    return null;
}
Also used : TextView(android.widget.TextView) URLSpan(android.text.style.URLSpan) Spanned(android.text.Spanned)

Example 38 with URLSpan

use of android.text.style.URLSpan in project AndroidLife by CaMnter.

the class SpanRecyclerAdapter method setSpanContent.

@SuppressLint("SetTextI18n")
public void setSpanContent(TextView labelTV, TextView contentTV, String content, int position) {
    SpannableStringBuilder ssb = new SpannableStringBuilder(content);
    String sub = "Save";
    int start = content.indexOf("Save");
    switch(position) {
        case URL_SPAN:
            {
                labelTV.setText("URLSpan");
                ssb.setSpan(new URLSpan("https://github.com/CaMnter"), start, sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                // 在单击链接时凡是有要执行的动作,都必须设置MovementMethod对象
                contentTV.setMovementMethod(LinkMovementMethod.getInstance());
                // 设置点击后的颜色,这里涉及到ClickableSpan的点击背景
                contentTV.setHighlightColor(0xff8FABCC);
                break;
            }
        case UNDERLINE_SPAN:
            {
                labelTV.setText("UnderlineSpan");
                ssb.setSpan(new UnderlineSpan(), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case TYPEFACE_SPAN:
            {
                labelTV.setText("TypefaceSpan ( Examples include \"monospace\", \"serif\", and \"sans-serif\". )");
                ssb.setSpan(new TypefaceSpan("serif"), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case TEXT_APPERARANCE_SPAN:
            {
                labelTV.setText("TextAppearanceSpan");
                ColorStateList colorStateList;
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                    colorStateList = this.activity.getColorStateList(R.color.selector_apperarance_span);
                } else {
                    colorStateList = this.activity.getResources().getColorStateList(R.color.selector_apperarance_span);
                }
                ssb.setSpan(new TextAppearanceSpan("serif", Typeface.BOLD_ITALIC, this.activity.getResources().getDimensionPixelSize(R.dimen.text_appearance_span), colorStateList, colorStateList), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case TAB_STOP_SPAN:
            {
                labelTV.setText("TabStopSpan.Standard");
                String[] subs = content.split(" ");
                ssb = new SpannableStringBuilder();
                /**
                 * TabStopSpan. Standard related to \t and \n
                 * TabStopSpan.Standard 跟 \t 和 \n 有关系
                 */
                for (String sub1 : subs) {
                    ssb.append("\t").append(sub1).append(" ");
                    ssb.append("\n");
                }
                ssb.setSpan(new TabStopSpan.Standard(126), 0, ssb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case SUPERS_SCRIPT_SPAN:
            {
                labelTV.setText("SuperscriptSpan");
                ssb.replace(start, start + sub.length(), "Save6");
                Parcel parcel = Parcel.obtain();
                parcel.writeInt(6);
                int sixPosition = ssb.toString().indexOf("6");
                ssb.setSpan(new SuperscriptSpan(parcel), sixPosition, sixPosition + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                parcel.recycle();
                contentTV.setText(ssb);
                break;
            }
        case SUB_SCRIPT_SPAN:
            {
                labelTV.setText("SubscriptSpan");
                ssb.replace(start, start + sub.length(), "Save6");
                Parcel parcel = Parcel.obtain();
                parcel.writeInt(6);
                int sixPosition = ssb.toString().indexOf("6");
                ssb.setSpan(new SubscriptSpan(parcel), sixPosition, sixPosition + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                parcel.recycle();
                contentTV.setText(ssb);
                break;
            }
        case STRIKE_THROUGH_SPAN:
            {
                labelTV.setText("StrikethroughSpan");
                ssb.setSpan(new StrikethroughSpan(), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case SCALE_X_SPAN:
            {
                labelTV.setText("ScaleXSpan");
                ssb.setSpan(new ScaleXSpan(2.0f), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case STYLE_SPAN:
            {
                labelTV.setText("StyleSpan ( Typeface.NORMAL,Typeface.BOLD,Typeface.ITALIC,Typeface.BOLD_ITALIC ) ");
                ssb.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case RELATIVE_SIZE_SPAN:
            {
                labelTV.setText("RelativeSizeSpan");
                ssb.setSpan(new RelativeSizeSpan(6.0f), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case QUOTO_SPAN:
            {
                labelTV.setText("QuoteSpan");
                ssb.setSpan(new QuoteSpan(0xff000000), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case MASK_FILTER_SPAN:
            {
                labelTV.setText("MaskFilterSpan ( BlurMaskFilter EmbossMaskFilter ) \n Activity: android:hardwareAccelerated=\"false\"\n ");
                MaskFilterSpan embossMaskFilterSpan = new MaskFilterSpan(new EmbossMaskFilter(new float[] { 3, 3, 9 }, 3.0f, 12, 16));
                ssb.setSpan(embossMaskFilterSpan, start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                String you = "you";
                int indexYou = content.indexOf(you);
                MaskFilterSpan blurMaskFilterSpan = new MaskFilterSpan(new BlurMaskFilter(3, BlurMaskFilter.Blur.OUTER));
                ssb.setSpan(blurMaskFilterSpan, indexYou, indexYou + you.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case LEADING_MARGIN_SPAN:
            {
                labelTV.setText("LeadingMarginSpan");
                ssb.append(" ").append(ssb.toString()).append(ssb.toString()).append(ssb.toString());
                ssb.setSpan(new LeadingMarginSpan.Standard(96, 36), 0, ssb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case IMAGE_SPAN:
            {
                labelTV.setText("ImageSpan");
                ssb.replace(start, start + sub.length(), " Save");
                ssb.setSpan(new ImageSpan(this.activity, R.drawable.ic_mm_normal, ImageSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case ICON_MARGIN_SPAN:
            {
                labelTV.setText("IconMarginSpan");
                Bitmap bitmap = BitmapFactory.decodeResource(this.activity.getResources(), R.drawable.ic_mm_normal);
                ssb.setSpan(new IconMarginSpan(bitmap, 60), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                // bitmap.recycle();
                contentTV.setText(ssb);
                break;
            }
        case FOREGROUND_COLOR_SPAN:
            {
                labelTV.setText("ForegroundColorSpan");
                ssb.setSpan(new ForegroundColorSpan(0xff303F9F), start, start + sub.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case DRAWABLE_MARGIN_SPAN:
            {
                labelTV.setText("DrawableMarginSpan");
                ssb.setSpan(new DrawableMarginSpan(ResourcesUtils.getDrawable(this.activity, R.drawable.ic_mm_normal), 6), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case BULLET_SPAN:
            {
                labelTV.setText("BulletSpan");
                ssb.setSpan(new BulletSpan(66, 0xff303F9F), start, start + sub.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case BACKGROUND_COLOR_SPAN:
            {
                labelTV.setText("BackgroundColorSpan");
                String you = "you";
                int indexYou = content.indexOf(you);
                ssb.setSpan(new BackgroundColorSpan(0x2f303F9F), start, start + sub.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new BackgroundColorSpan(0x2fFF4081), indexYou, indexYou + you.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case ALIGNMENT_SPAN_STANDARD:
            {
                labelTV.setText("AlignmentSpan.Standard");
                ssb.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case ABSOLUTE_SIZE_SPAN:
            {
                labelTV.setText("AbsoluteSizeSpan");
                ssb.setSpan(new AbsoluteSizeSpan(26, true), start, start + sub.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                break;
            }
        case CLICKABLE_SPAN:
            {
                labelTV.setText("ClickableSpan ( Please click \"Save\" )");
                SpanClickableSpan spanClickableSpan = new SpanClickableSpan(0xffFF4081, new ClickableSpanNoUnderline.OnClickListener<SpanClickableSpan>() {

                    /**
                     * ClickableSpan被点击
                     *
                     * @param widget widget
                     * @param span   span
                     */
                    @Override
                    public void onClick(View widget, SpanClickableSpan span) {
                        String urlString = span.getUrlString();
                        if (TextUtils.isEmpty(urlString))
                            return;
                        Uri uri = Uri.parse(urlString);
                        Context context = widget.getContext();
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
                        try {
                            context.startActivity(intent);
                        } catch (ActivityNotFoundException e) {
                            Log.w("URLSpan", "Activity was not found for intent, " + intent.toString());
                        }
                    }
                });
                spanClickableSpan.setUrlString("https://github.com/CaMnter");
                ssb.setSpan(spanClickableSpan, start, start + sub.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                contentTV.setText(ssb);
                // 在单击链接时凡是有要执行的动作,都必须设置MovementMethod对象
                contentTV.setMovementMethod(LinkMovementMethod.getInstance());
                // 设置点击后的颜色,这里涉及到ClickableSpan的点击背景
                contentTV.setHighlightColor(0x00000000);
                break;
            }
    }
}
Also used : TextAppearanceSpan(android.text.style.TextAppearanceSpan) SuperscriptSpan(android.text.style.SuperscriptSpan) ColorStateList(android.content.res.ColorStateList) ScaleXSpan(android.text.style.ScaleXSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) QuoteSpan(android.text.style.QuoteSpan) EmbossMaskFilter(android.graphics.EmbossMaskFilter) URLSpan(android.text.style.URLSpan) Uri(android.net.Uri) Bitmap(android.graphics.Bitmap) IconMarginSpan(android.text.style.IconMarginSpan) SubscriptSpan(android.text.style.SubscriptSpan) Context(android.content.Context) DrawableMarginSpan(android.text.style.DrawableMarginSpan) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Parcel(android.os.Parcel) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) UnderlineSpan(android.text.style.UnderlineSpan) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan) MaskFilterSpan(android.text.style.MaskFilterSpan) BulletSpan(android.text.style.BulletSpan) ActivityNotFoundException(android.content.ActivityNotFoundException) StyleSpan(android.text.style.StyleSpan) BlurMaskFilter(android.graphics.BlurMaskFilter) SpannableStringBuilder(android.text.SpannableStringBuilder) BackgroundColorSpan(android.text.style.BackgroundColorSpan) TypefaceSpan(android.text.style.TypefaceSpan) StrikethroughSpan(android.text.style.StrikethroughSpan) ImageSpan(android.text.style.ImageSpan) SuppressLint(android.annotation.SuppressLint)

Example 39 with URLSpan

use of android.text.style.URLSpan in project iNaturalistAndroid by inaturalist.

the class GuideTaxonActivity method stripUnderlines.

private void stripUnderlines(TextView textView) {
    Spannable s = (Spannable) textView.getText();
    URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
    for (URLSpan span : spans) {
        int start = s.getSpanStart(span);
        int end = s.getSpanEnd(span);
        s.removeSpan(span);
        span = new URLSpanNoUnderline(span.getURL());
        s.setSpan(span, start, end, 0);
    }
    textView.setText(s);
}
Also used : URLSpan(android.text.style.URLSpan) Spannable(android.text.Spannable) TextPaint(android.text.TextPaint)

Example 40 with URLSpan

use of android.text.style.URLSpan in project ForPDA by RadiationX.

the class HtmlToSpannedConverter method withinParagraph.

private static void withinParagraph(StringBuilder out, Spanned text, int start, int end) {
    int next;
    for (int i = start; i < end; i = next) {
        next = text.nextSpanTransition(i, end, CharacterStyle.class);
        CharacterStyle[] style = text.getSpans(i, next, CharacterStyle.class);
        for (int j = 0; j < style.length; j++) {
            if (style[j] instanceof StyleSpan) {
                int s = ((StyleSpan) style[j]).getStyle();
                if ((s & Typeface.BOLD) != 0) {
                    out.append("<b>");
                }
                if ((s & Typeface.ITALIC) != 0) {
                    out.append("<i>");
                }
            }
            if (style[j] instanceof TypefaceSpan) {
                String s = ((TypefaceSpan) style[j]).getFamily();
                if ("monospace".equals(s)) {
                    out.append("<tt>");
                }
            }
            if (style[j] instanceof SuperscriptSpan) {
                out.append("<sup>");
            }
            if (style[j] instanceof SubscriptSpan) {
                out.append("<sub>");
            }
            if (style[j] instanceof UnderlineSpan) {
                out.append("<u>");
            }
            if (style[j] instanceof StrikethroughSpan) {
                out.append("<span style=\"text-decoration:line-through;\">");
            }
            if (style[j] instanceof URLSpan) {
                out.append("<a href=\"");
                out.append(((URLSpan) style[j]).getURL());
                out.append("\">");
            }
            if (style[j] instanceof ImageSpan) {
                out.append("<img src=\"");
                out.append(((ImageSpan) style[j]).getSource());
                out.append("\">");
                // Don't output the dummy character underlying the image.
                i = next;
            }
            if (style[j] instanceof AbsoluteSizeSpan) {
                AbsoluteSizeSpan s = ((AbsoluteSizeSpan) style[j]);
                float sizeDip = s.getSize();
                if (!s.getDip()) {
                    Application application = App.get();
                    sizeDip /= application.getResources().getDisplayMetrics().density;
                }
                // px in CSS is the equivalance of dip in Android
                out.append(String.format("<span style=\"font-size:%.0fpx\";>", sizeDip));
            }
            if (style[j] instanceof RelativeSizeSpan) {
                float sizeEm = ((RelativeSizeSpan) style[j]).getSizeChange();
                out.append(String.format("<span style=\"font-size:%.2fem;\">", sizeEm));
            }
            if (style[j] instanceof ForegroundColorSpan) {
                int color = ((ForegroundColorSpan) style[j]).getForegroundColor();
                out.append(String.format("<span style=\"color:#%06X;\">", 0xFFFFFF & color));
            }
            if (style[j] instanceof BackgroundColorSpan) {
                int color = ((BackgroundColorSpan) style[j]).getBackgroundColor();
                out.append(String.format("<span style=\"background-color:#%06X;\">", 0xFFFFFF & color));
            }
        }
        withinStyle(out, text, i, next);
        for (int j = style.length - 1; j >= 0; j--) {
            if (style[j] instanceof BackgroundColorSpan) {
                out.append("</span>");
            }
            if (style[j] instanceof ForegroundColorSpan) {
                out.append("</span>");
            }
            if (style[j] instanceof RelativeSizeSpan) {
                out.append("</span>");
            }
            if (style[j] instanceof AbsoluteSizeSpan) {
                out.append("</span>");
            }
            if (style[j] instanceof URLSpan) {
                out.append("</a>");
            }
            if (style[j] instanceof StrikethroughSpan) {
                out.append("</span>");
            }
            if (style[j] instanceof UnderlineSpan) {
                out.append("</u>");
            }
            if (style[j] instanceof SubscriptSpan) {
                out.append("</sub>");
            }
            if (style[j] instanceof SuperscriptSpan) {
                out.append("</sup>");
            }
            if (style[j] instanceof TypefaceSpan) {
                String s = ((TypefaceSpan) style[j]).getFamily();
                if (s.equals("monospace")) {
                    out.append("</tt>");
                }
            }
            if (style[j] instanceof StyleSpan) {
                int s = ((StyleSpan) style[j]).getStyle();
                if ((s & Typeface.BOLD) != 0) {
                    out.append("</b>");
                }
                if ((s & Typeface.ITALIC) != 0) {
                    out.append("</i>");
                }
            }
        }
    }
}
Also used : SuperscriptSpan(android.text.style.SuperscriptSpan) ForegroundColorSpan(android.text.style.ForegroundColorSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) URLSpan(android.text.style.URLSpan) CharacterStyle(android.text.style.CharacterStyle) UnderlineSpan(android.text.style.UnderlineSpan) AbsoluteSizeSpan(android.text.style.AbsoluteSizeSpan) StyleSpan(android.text.style.StyleSpan) SubscriptSpan(android.text.style.SubscriptSpan) Application(android.app.Application) BackgroundColorSpan(android.text.style.BackgroundColorSpan) TypefaceSpan(android.text.style.TypefaceSpan) StrikethroughSpan(android.text.style.StrikethroughSpan) ImageSpan(android.text.style.ImageSpan)

Aggregations

URLSpan (android.text.style.URLSpan)134 SpannableString (android.text.SpannableString)36 Spannable (android.text.Spannable)22 SpannableStringBuilder (android.text.SpannableStringBuilder)21 TextPaint (android.text.TextPaint)21 Spanned (android.text.Spanned)20 TextView (android.widget.TextView)19 ForegroundColorSpan (android.text.style.ForegroundColorSpan)16 StyleSpan (android.text.style.StyleSpan)16 UnderlineSpan (android.text.style.UnderlineSpan)14 Paint (android.graphics.Paint)13 ImageSpan (android.text.style.ImageSpan)13 StrikethroughSpan (android.text.style.StrikethroughSpan)13 TypefaceSpan (android.text.style.TypefaceSpan)13 View (android.view.View)13 Intent (android.content.Intent)12 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)12 BackgroundColorSpan (android.text.style.BackgroundColorSpan)12 ClickableSpan (android.text.style.ClickableSpan)12 SubscriptSpan (android.text.style.SubscriptSpan)12