Example usage for android.text.style StrikethroughSpan StrikethroughSpan

List of usage examples for android.text.style StrikethroughSpan StrikethroughSpan

Introduction

In this page you can find the example usage for android.text.style StrikethroughSpan StrikethroughSpan.

Prototype

public StrikethroughSpan() 

Source Link

Document

Creates a StrikethroughSpan .

Usage

From source file:io.realm.realmtasks.list.ItemViewHolder.java

public void setStrikeThroughRatio(float strikeThroughRatio) {
    final CharSequence text = this.text.getText();
    final int textLength = text.length();
    int firstLength = (int) (textLength * strikeThroughRatio);
    if (firstLength > textLength) {
        firstLength = textLength;/*  w  w  w  .jav  a2  s  .c  om*/
    } else if (firstLength == textLength - 1) {
        firstLength = textLength;
    }
    if (firstLength == previousFirstLength) {
        return;
    }
    previousFirstLength = firstLength;
    final int appendedLength = textLength - firstLength;
    final SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text, 0, textLength);
    stringBuilder.clearSpans();
    this.text.setPaintFlags(this.text.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
    final CharacterStyle firstCharStyle, secondCharStyle;
    if (completed) {
        firstCharStyle = new ForegroundColorSpan(cellCompletedColor);
        secondCharStyle = new StrikethroughSpan();
    } else {
        firstCharStyle = new StrikethroughSpan();
        secondCharStyle = new ForegroundColorSpan(cellDefaultColor);
    }
    stringBuilder.setSpan(firstCharStyle, 0, firstLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    stringBuilder.setSpan(secondCharStyle, textLength - appendedLength, textLength,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    this.text.setText(stringBuilder);
}

From source file:com.avapira.bobroreader.hanabira.HanabiraParser.java

private void formatWordStrike() {
    int removedCharactersDelta = 0;
    Pattern pattern = Pattern.compile("(\\^W)+");
    Matcher matcher = pattern.matcher(builder);
    while (matcher.find()) {
        final int start = matcher.start() - removedCharactersDelta;
        final int end = matcher.end() - removedCharactersDelta;
        CodeBlockSpan[] spans = builder.getSpans(start, start, CodeBlockSpan.class);
        if (spans != null && spans.length != 0) {
            continue;
        }/*from   w w  w .ja v  a2 s. c  o  m*/

        int wordsAmount = matcher.group().length() / 2;
        char[] chars = new char[builder.length()];
        builder.getChars(0, builder.length(), chars, 0);
        int runner = start;
        try {
            while (wordsAmount > 0) {
                if (Character.isSpaceChar(chars[runner--])) {
                    wordsAmount--;
                }
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            runner = 0;
        }
        builder.setSpan(new StrikethroughSpan(), runner, start, 0);
        builder.delete(start, end);
        removedCharactersDelta = end - start;
    }
}

From source file:com.avapira.bobroreader.hanabira.HanabiraParser.java

private void formatCharStrike() {
    int removedFormatCharsDelta = 0;
    Pattern pattern = Pattern.compile("(\\^H)+");
    Matcher matcher = pattern.matcher(builder);
    while (matcher.find()) {
        int pos_start = matcher.start() - removedFormatCharsDelta;
        int pos_end = matcher.end() - removedFormatCharsDelta;
        // don't reformat in code blocks
        CodeBlockSpan[] spans = builder.getSpans(pos_start, pos_end, CodeBlockSpan.class);
        if (spans != null && spans.length != 0) {
            continue;
        }//from w  ww .jav  a2 s .co  m

        builder.setSpan(new StrikethroughSpan(), pos_start - (pos_end - pos_start) / 2, pos_start, 0);
        builder.delete(pos_start, pos_end);
        removedFormatCharsDelta += pos_end - pos_start;
    }
}

From source file:com.nearnotes.NoteEdit.java

/**
 * Populates the checkboxes on the side by analyzing the current text from
 * the body of the note.//from w ww  . j  a  v  a  2 s.  c  o  m
 * 
 * @param currentString
 *            the current body of the note.
 * 
 */
public ArrayList<NoteRow> populateBoxes(String currentString) {

    // Load ArrayList<String> mLines with the current bodytext seperated into seperate lines.
    mLines = Arrays.asList(currentString.split(System.getProperty("line.separator")));

    // row counter to determine what the current line number is for the for loop
    int row = 0;

    // realRow counter to determine what line of text in the actual display we are on
    // used to get the number of characters on each line
    int realRow = 0;
    int activeRow = 0;
    int finishedCount = 0;

    ArrayList<NoteRow> tempRealRow = new ArrayList<NoteRow>();
    for (String line : mLines) {
        NoteRow temp = new NoteRow(0, 1, row); // Create a note row object with rowType of 0 (invisible), lineSize of 1 and the current row number

        if (!line.isEmpty()) {
            activeRow++;
            temp.setType(1); // Set the NoteRow object to 1 (visible)

            // Determine how many lines the note takes up
            int internalCounter = 0;
            try {
                float lineLength = (float) line.length();
                for (int k = 0; (lineLength
                        / (getFloatLineEnd(realRow + k) - getFloatLineEnd(realRow - 1))) > 1; k++) {
                    internalCounter++;
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

            // Detemine if the note is supposed to be checked and set the NoteRow object to 2 (Checked)
            if (line.startsWith("[X]")) {
                finishedCount++;
                int spanstart = 0;
                StrikethroughSpan STRIKE_THROUGH_SPAN = new StrikethroughSpan();
                Spannable spannable = (Spannable) mBodyText.getText();
                // TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null);

                for (int j = 0; j < row; j++) {
                    spanstart += mLines.get(j).length() + 1;
                }

                Object spansToRemove[] = spannable.getSpans(spanstart, spanstart + mLines.get(row).length(),
                        Object.class);
                for (Object span : spansToRemove) {
                    if (span instanceof CharacterStyle)
                        spannable.removeSpan(span);
                }

                spannable.setSpan(STRIKE_THROUGH_SPAN, spanstart, spanstart + mLines.get(row).length(),
                        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                temp.setType(2);
            }

            temp.setSize(1 + internalCounter); // Set the amount of rows the note takes up
            realRow = realRow + internalCounter; // Determine the real line on the display text we are on
        }

        tempRealRow.add(temp); // NoteRow object has been finalized - add to the ListArray<NoteRow>
        realRow++; // Increase the noteRow and the displayRow for the next line
        row++;
    }

    if (finishedCount == activeRow && finishedCount != 0) {

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
        boolean useListPref = sharedPref.getBoolean("pref_key_use_checklist_default", false);
        String stringlistPref = sharedPref.getString("pref_key_checklist_listPref", "2");
        int listPref = Integer.parseInt(stringlistPref);

        ChecklistDialog newFragment = new ChecklistDialog();
        if (mRowId == null) {
            saveState();
        }
        Bundle args = new Bundle();
        args.putLong("_id", mRowId);
        args.putBoolean("useDefault", useListPref);
        args.putInt("listPref", listPref);
        newFragment.setArguments(args);
        if (listPref == 2 && useListPref) {
            return tempRealRow;
        }
        if (getFragmentManager().findFragmentByTag("MyDialog") == null) {
            newFragment.show(getFragmentManager(), "MyDialog");
        }

    }

    return tempRealRow;
}

From source file:ayushi.view.fragment.ProductDetailsFragment.java

public void fillProductData() {

    if (!isFromCart) {

        //Fetch and display item from Gloabl Data Model

        itemName.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                .get(productListNumber).getItemName());

        quanitity.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                .get(productListNumber).getQuantity());

        itemdescription.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                .get(productListNumber).getItemDetail());

        String sellCostString = Money.rupees(BigDecimal.valueOf(Long.valueOf(GlobaDataHolder
                .getGlobaDataHolder().getProductMap().get(subcategoryKey).get(productListNumber).getSellMRP())))
                .toString() + "  ";

        String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(GlobaDataHolder.getGlobaDataHolder()
                .getProductMap().get(subcategoryKey).get(productListNumber).getMRP()))).toString();

        String costString = sellCostString + buyMRP;

        itemSellPrice.setText(costString, BufferType.SPANNABLE);

        Spannable spannable = (Spannable) itemSellPrice.getText();

        spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10);

        drawable = mDrawableBuilder.build(
                String.valueOf(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                        .get(productListNumber).getItemName().charAt(0)),
                mColorGenerator.getColor(GlobaDataHolder.getGlobaDataHolder().getProductMap()
                        .get(subcategoryKey).get(productListNumber).getItemName()));

        Picasso.with(getActivity())//from  w ww .ja  v  a2  s . co  m
                .load(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                        .get(productListNumber).getImageURL())
                .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE)
                .into(itemImage, new Callback() {
                    @Override
                    public void onSuccess() {

                    }

                    @Override
                    public void onError() {
                        // Try again online if cache failed

                        Picasso.with(getActivity())
                                .load(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                                        .get(productListNumber).getImageURL())
                                .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage);
                    }
                });

        LabelView label = new LabelView(getActivity());

        label.setText(GlobaDataHolder.getGlobaDataHolder().getProductMap().get(subcategoryKey)
                .get(productListNumber).getDiscount());
        label.setBackgroundColor(0xffE91E63);

        label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP);
    } else {

        //Fetch and display products from Shopping list

        itemName.setText(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getItemName());

        quanitity.setText(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getQuantity());

        itemdescription.setText(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getItemDetail());

        String sellCostString = Money.rupees(BigDecimal.valueOf(Long.valueOf(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getSellMRP())))
                .toString() + "  ";

        String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getMRP())))
                .toString();

        String costString = sellCostString + buyMRP;

        itemSellPrice.setText(costString, BufferType.SPANNABLE);

        Spannable spannable = (Spannable) itemSellPrice.getText();

        spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10);

        drawable = mDrawableBuilder.build(
                String.valueOf(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber)
                        .getItemName().charAt(0)),
                mColorGenerator.getColor(GlobaDataHolder.getGlobaDataHolder().getShoppingList()
                        .get(productListNumber).getItemName()));

        Picasso.with(getActivity())
                .load(GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber)
                        .getImageURL())
                .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE)
                .into(itemImage, new Callback() {
                    @Override
                    public void onSuccess() {

                    }

                    @Override
                    public void onError() {
                        // Try again online if cache failed

                        Picasso.with(getActivity())
                                .load(GlobaDataHolder.getGlobaDataHolder().getShoppingList()
                                        .get(productListNumber).getImageURL())
                                .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage);
                    }
                });

        LabelView label = new LabelView(getActivity());

        label.setText(
                GlobaDataHolder.getGlobaDataHolder().getShoppingList().get(productListNumber).getDiscount());
        label.setBackgroundColor(0xffE91E63);

        label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP);

    }
}

From source file:com.hitesh_sahu.retailapp.view.fragment.ProductDetailsFragment.java

public void fillProductData() {

    if (!isFromCart) {

        //Fetch and display item from Gloabl Data Model

        itemName.setText(CenterRepository.getCenterRepository().getMapOfProductsInCategory().get(subcategoryKey)
                .get(productListNumber).getItemName());

        quanitity.setText(CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                .get(subcategoryKey).get(productListNumber).getQuantity());

        itemdescription.setText(CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                .get(subcategoryKey).get(productListNumber).getItemDetail());

        String sellCostString = Money
                .rupees(BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                        .getMapOfProductsInCategory().get(subcategoryKey).get(productListNumber).getSellMRP())))
                .toString() + "  ";

        String buyMRP = Money/*from   w  ww .jav a2  s . c  o  m*/
                .rupees(BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                        .getMapOfProductsInCategory().get(subcategoryKey).get(productListNumber).getMRP())))
                .toString();

        String costString = sellCostString + buyMRP;

        itemSellPrice.setText(costString, BufferType.SPANNABLE);

        Spannable spannable = (Spannable) itemSellPrice.getText();

        spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10);

        drawable = mDrawableBuilder.build(
                String.valueOf(CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber).getItemName().charAt(0)),
                mColorGenerator.getColor(CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber).getItemName()));

        Picasso.with(getActivity())
                .load(CenterRepository.getCenterRepository().getMapOfProductsInCategory().get(subcategoryKey)
                        .get(productListNumber).getImageURL())
                .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE)
                .into(itemImage, new Callback() {
                    @Override
                    public void onSuccess() {

                    }

                    @Override
                    public void onError() {
                        // Try again online if cache failed

                        Picasso.with(getActivity())
                                .load(CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                        .get(subcategoryKey).get(productListNumber).getImageURL())
                                .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage);
                    }
                });

        LabelView label = new LabelView(getActivity());

        label.setText(CenterRepository.getCenterRepository().getMapOfProductsInCategory().get(subcategoryKey)
                .get(productListNumber).getDiscount());
        label.setBackgroundColor(0xffE91E63);

        label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP);
    } else {

        //Fetch and display products from Shopping list

        itemName.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                .get(productListNumber).getItemName());

        quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                .get(productListNumber).getQuantity());

        itemdescription.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                .get(productListNumber).getItemDetail());

        String sellCostString = Money
                .rupees(BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                        .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())))
                .toString() + "  ";

        String buyMRP = Money.rupees(BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                .getListOfProductsInShoppingList().get(productListNumber).getMRP()))).toString();

        String costString = sellCostString + buyMRP;

        itemSellPrice.setText(costString, BufferType.SPANNABLE);

        Spannable spannable = (Spannable) itemSellPrice.getText();

        spannable.setSpan(new StrikethroughSpan(), sellCostString.length(), costString.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        mDrawableBuilder = TextDrawable.builder().beginConfig().withBorder(4).endConfig().roundRect(10);

        drawable = mDrawableBuilder.build(
                String.valueOf(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getItemName().charAt(0)),
                mColorGenerator.getColor(CenterRepository.getCenterRepository()
                        .getListOfProductsInShoppingList().get(productListNumber).getItemName()));

        Picasso.with(getActivity())
                .load(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getImageURL())
                .placeholder(drawable).error(drawable).fit().centerCrop().networkPolicy(NetworkPolicy.OFFLINE)
                .into(itemImage, new Callback() {
                    @Override
                    public void onSuccess() {

                    }

                    @Override
                    public void onError() {
                        // Try again online if cache failed

                        Picasso.with(getActivity())
                                .load(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                        .get(productListNumber).getImageURL())
                                .placeholder(drawable).error(drawable).fit().centerCrop().into(itemImage);
                    }
                });

        LabelView label = new LabelView(getActivity());

        label.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                .get(productListNumber).getDiscount());
        label.setBackgroundColor(0xffE91E63);

        label.setTargetView(itemImage, 10, LabelView.Gravity.RIGHT_TOP);

    }
}

From source file:com.nttec.everychan.ui.presentation.HtmlParser.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("s")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endBlockquote(mSpannableStringBuilder, mColors);
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("code")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("ul")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();//from w w  w.j av a 2  s .  c  om
    } else if (tag.equalsIgnoreCase("ol")) {
        if (!mListTags.isEmpty())
            mListTags.removeFirst();
    } else if (tag.equalsIgnoreCase("li")) {
        //??  ?? <li>
    } else if (tag.equalsIgnoreCase("tr")) {
        handleTr(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("td")) {
        handleTd(mSpannableStringBuilder, false);
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        handleP(mSpannableStringBuilder, mStartLength, mLastPTagLength);
        endHeader(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endSpan(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } else if (tag.equalsIgnoreCase("aibquote")) {
        end(mSpannableStringBuilder, Aibquote.class,
                new ForegroundColorSpan(mColors != null ? mColors.quoteForeground : Color.GREEN));
    } else if (tag.equalsIgnoreCase("aibspoiler")) {
        endAibspoiler(mSpannableStringBuilder, mColors, mOpenSpoilers);
    } /* else if (mTagHandler != null) {
      mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
      }*/
}

From source file:com.nttec.everychan.ui.presentation.HtmlParser.java

private static void endSpan(SpannableStringBuilder text, ThemeColors colors, boolean openSpoilers) {
    int len = text.length();
    Object obj = getLast(text, Span.class);
    int where = text.getSpanStart(obj);
    text.removeSpan(obj);//w  w w .  ja v  a  2  s . co  m

    if (where != len) {
        Span s = (Span) obj;

        if (s.mStyle != null) {
            List<Object> styleSpans = parseStyleAttributes(s.mStyle);
            for (Object span : styleSpans) {
                text.setSpan(span, where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }

        if (colors != null && s.mIsAibquote) {
            text.setSpan(new ForegroundColorSpan(colors.quoteForeground), where, len,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if (colors != null && s.mIsAibspoiler) {
            if (openSpoilers) {
                text.setSpan(new ForegroundColorSpan(colors.spoilerForeground), where, len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                text.setSpan(new BackgroundColorSpan(colors.spoilerBackground), where, len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            } else {
                text.setSpan(new SpoilerSpan(colors.spoilerForeground, colors.spoilerBackground), where, len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }

        if (s.mIsUnderline) {
            text.setSpan(new UnderlineSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if (s.mIsStrike) {
            text.setSpan(new StrikethroughSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

    }
}

From source file:org.miaowo.miaowo.util.Html.java

private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        endCssStyle(mSpannableStringBuilder);
        endBlockElement(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("ul")) {
        endBlockElement(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("li")) {
        endLi(mSpannableStringBuilder);//from  w ww .j  av  a2 s. co m
    } else if (tag.equalsIgnoreCase("div")) {
        endBlockElement(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endCssStyle(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        endBlockquote(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("s")) {
        end(mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(mSpannableStringBuilder, Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 && Character.toLowerCase(tag.charAt(0)) == 'h' && tag.charAt(1) >= '1'
            && tag.charAt(1) <= '6') {
        endHeading(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}