Java Code Examples for android.text.style.SuperscriptSpan

The following are top voted examples for showing how to use android.text.style.SuperscriptSpan. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: android_packages_apps_tv   File: CaptionWindowLayout.java   Source Code and License 6 votes vote down vote up
public void setPenAttr(CaptionPenAttr penAttr) {
    mCharacterStyles.clear();
    if (penAttr.italic) {
        mCharacterStyles.add(new StyleSpan(Typeface.ITALIC));
    }
    if (penAttr.underline) {
        mCharacterStyles.add(new UnderlineSpan());
    }
    switch (penAttr.penSize) {
        case CaptionPenAttr.PEN_SIZE_SMALL:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_SMALL));
            break;
        case CaptionPenAttr.PEN_SIZE_LARGE:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_LARGE));
            break;
    }
    switch (penAttr.penOffset) {
        case CaptionPenAttr.OFFSET_SUBSCRIPT:
            mCharacterStyles.add(new SubscriptSpan());
            break;
        case CaptionPenAttr.OFFSET_SUPERSCRIPT:
            mCharacterStyles.add(new SuperscriptSpan());
            break;
    }
}
 
Example 2
Project: android-tibits   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_main);

    Spanned spanned = null;

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        spanned = Html.fromHtml(getString(R.string.android_html_text));
    } else {
        spanned = Html.fromHtml(getString(R.string.android_html_text), Html.FROM_HTML_MODE_COMPACT);
    }

    SpannableStringBuilder builder = new SpannableStringBuilder(spanned);

    StyleSpan[] styleSpanArray = builder.getSpans(0, builder.length(), StyleSpan.class);
    SuperscriptSpan[] superscriptSpanArray = builder.getSpans(0, builder.length(), SuperscriptSpan.class);

    mCreateTypeface();
    mCustomiseStyleSpan(styleSpanArray, builder);
    mCustomiseScriptSpan(superscriptSpanArray, builder);

    TextView textView = (TextView)findViewById(R.id.text_view);
    textView.setTypeface(mRegularTypeface);
    textView.setText(builder, TextView.BufferType.SPANNABLE);
}
 
Example 3
Project: memoir   File: ConverterSpannedToHtml.java   Source Code and License 6 votes vote down vote up
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
Example 4
Project: memoir   File: ConverterSpannedToHtml.java   Source Code and License 6 votes vote down vote up
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
Example 5
Project: Doctor   File: ConverterSpannedToHtml.java   Source Code and License 6 votes vote down vote up
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
Example 6
Project: nono-android   File: MyHtmlTagHandler.java   Source Code and License 6 votes vote down vote up
private void processSup( boolean opening, Editable output) {
    int len = output.length();
    if(opening) {
        //output.setSpan(new AbsoluteSizeSpan(scriptSize,false), len, len, Spannable.SPAN_MARK_MARK);
        //output.setSpan(new RelativeSizeSpan(0.5f), len, len, Spannable.SPAN_MARK_MARK);
        output.setSpan(new SuperscriptSpan(), len, len, Spannable.SPAN_MARK_MARK);
    } else {
        Object obj = getLast(output, SuperscriptSpan.class);
        int where = output.getSpanStart(obj);
        output.removeSpan(obj);
        //obj = getLast(output, RelativeSizeSpan.class);
        //output.removeSpan(obj);
        if (where != len&&where>=0) {
            //output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new RelativeSizeSpan(0.7f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new SuperscriptSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        //obj = getLast(output, AbsoluteSizeSpan.class);
        //where = output.getSpanStart(obj);
        //output.removeSpan(obj);
        //if (where != len) {
        //    output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //    //output.setSpan(new RelativeSizeSpan(0.5f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //}
    }
}
 
Example 7
Project: materialistic   File: HelpListView.java   Source Code and License 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ((TextView) findViewById(R.id.item_new).findViewById(R.id.rank))
            .append(makeAsteriskSpan());
    SpannableString spannable = new SpannableString("+5");
    spannable.setSpan(new SuperscriptSpan(), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new RelativeSizeSpan(0.6f), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(
            ContextCompat.getColor(getContext(), R.color.greenA700)), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    ((TextView) findViewById(R.id.item_promoted).findViewById(R.id.rank)).append(spannable);
    TextView comments = (TextView) findViewById(R.id.item_new_comments).findViewById(R.id.comment);
    SpannableStringBuilder sb = new SpannableStringBuilder("46");
    sb.append(makeAsteriskSpan());
    comments.setText(sb);
}
 
Example 8
Project: Android-RTEditor   File: ConverterSpannedToHtml.java   Source Code and License 6 votes vote down vote up
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
Example 9
Project: ParcelGen   File: ParcelGenTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testCharSequence() {

    final Spannable.Factory factory = Spannable.Factory.getInstance();

    final Spannable single = factory.newSpannable("Hello Single Spannable");
    single.setSpan(new UnderlineSpan(), 0, single.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final Spannable s1 = factory.newSpannable("S1");
    s1.setSpan(new SuperscriptSpan(), 0, s1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final Spannable s2 = factory.newSpannable("[email protected]_dskfjsjdhfkjf");
    s2.setSpan(new StrikethroughSpan(), 0, s2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final SomeParcelableSibling sibling = new SomeParcelableSibling()
            .setCharSequence(single)
            .setCharSequenceArray(new CharSequence[]{s1, s2});

    assertParcelable(sibling, false);
}
 
Example 10
Project: SpanEZ   File: SpanEZTest.java   Source Code and License 5 votes vote down vote up
@Test
public void superscript_should_add_only_one_span() {
    spanBuilder.style(range, EZ.SUPERSCRIPT)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(SuperscriptSpan.class));
}
 
Example 11
Project: amap   File: MIP_TextStyle.java   Source Code and License 5 votes vote down vote up
public MIP_TextStyle setSuperscriptSpan(int start, int end)
{
    if (spannableString == null)
    {
        return this;
    }
    spannableString.setSpan(new SuperscriptSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 设置前景色为洋红色
    return this;
}
 
Example 12
Project: Matrix-Calculator-for-Android   File: FunctionMaker.java   Source Code and License 5 votes vote down vote up
private SpannableStringBuilder ConvertToExponent(String s) { //This Function makes the Normal text into Exponents and base, position being the index of exponent
    int position = s.indexOf("x") + 1;
    SpannableStringBuilder builder = new SpannableStringBuilder(s);
    builder.setSpan(new SuperscriptSpan(), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new RelativeSizeSpan(0.50f), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return builder;
}
 
Example 13
Project: spanner   File: Spans.java   Source Code and License 5 votes vote down vote up
/**
 * @see SuperscriptSpan#SuperscriptSpan()
 */
public static Span superscript() {
    return new Span(new SpanBuilder() {
        @Override
        public Object build() {
            return new SuperscriptSpan();
        }
    });
}
 
Example 14
Project: DailyStudy   File: SpannableStringActivity.java   Source Code and License 5 votes vote down vote up
/**
 * SuperscriptSpan,设置上标
 */
private void superscript () {
    SpannableString string = new SpannableString("为文字设置下划线");
    RelativeSizeSpan sizeSpan = new RelativeSizeSpan(0.7f);
    string.setSpan(sizeSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    SuperscriptSpan superscriptSpan = new SuperscriptSpan();
    string.setSpan(superscriptSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    bgtext.setText(string);
}
 
Example 15
Project: text-decorator   File: TextDecorator.java   Source Code and License 5 votes vote down vote up
public TextDecorator setSuperscript(final String... texts) {
  int index;

  for (String text : texts) {
    if (content.contains(text)) {
      index = content.indexOf(text);
      decoratedContent.setSpan(new SuperscriptSpan(), index, index + text.length(), flags);
    }
  }

  return this;
}
 
Example 16
Project: prayer-times-android   File: Utils.java   Source Code and License 5 votes vote down vote up
public static CharSequence fixTimeForHTML(String time) {
    time = fixTime(time);
    if (!Prefs.use12H()) {
        return time;
    }
    int d = time.indexOf(" ");
    if (d < 0) return time;
    time = time.replace(" ", "");

    int s = time.length();
    Spannable span = new SpannableString(time);
    span.setSpan(new SuperscriptSpan(), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    span.setSpan(new RelativeSizeSpan(0.5f), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return span;
}
 
Example 17
Project: Matrix-Calculator-for-Android   File: FunctionMaker.java   Source Code and License 5 votes vote down vote up
private SpannableStringBuilder ConvertToExponent(String s) { //This Function makes the Normal text into Exponents and base, position being the index of exponent
    int position = s.indexOf("x") + 1;
    SpannableStringBuilder builder = new SpannableStringBuilder(s);
    builder.setSpan(new SuperscriptSpan(), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new RelativeSizeSpan(0.50f), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return builder;
}
 
Example 18
Project: SimpleNews   File: BadgeView2.java   Source Code and License 5 votes vote down vote up
private CharSequence genMaxText() {
    SpannableStringBuilder ssb = new SpannableStringBuilder(
            String.valueOf(max) + "+");
    RelativeSizeSpan span = new RelativeSizeSpan(.8f);
    // ssb.setSpan(span, 2, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SuperscriptSpan span2 = new SuperscriptSpan();
    // ssb.setSpan(span2, 2, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}
 
Example 19
Project: nono-android   File: EditView.java   Source Code and License 5 votes vote down vote up
@Override
public void onSpanClick(SpanButton v) {
    View view=richEdit.findFocus();
    BaseRichEditText editText;
    if(view instanceof BaseRichEditText){
        editText=(BaseRichEditText)view;
    }else {
        return;
    }
    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
    int color=typedValue.data;
    switch (v.getSpan()){
        case SpanButton.SPAN_BOLD:editText.toggleBold();if(editText.isBold()){editText.applyStyleSpan(Typeface.BOLD);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.BOLD);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_ITALIC:editText.toggleItalic();if(editText.isItalic()){editText.applyStyleSpan(Typeface.ITALIC);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.ITALIC);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_STRIKETHROUGH:editText.toggleStrikethrough();if(editText.isStrikethrough()){editText.applySelectionSpan(StrikethroughSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(StrikethroughSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_UNDERLINE:editText.toggleUnderLine();if(editText.isUnderLine()){editText.applySelectionSpan(UnderlineSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(UnderlineSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_FOREGROUND:editText.toggleForegroundColor();if(editText.isForegroundColor()){editText.applyColorSpan(ForegroundColorSpan.class,v.getGroundColor());v.setColor(v.getGroundColor());}else {editText.removeSelectionSpan(ForegroundColorSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_BACKGROUND:editText.toggleBackgroundColor();if(editText.isBackgroundColor()){editText.applyColorSpan(BackgroundColorSpan.class,v.getGroundColor());v.setColor(v.getGroundColor());}else {editText.removeSelectionSpan(BackgroundColorSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_SUBSCRIPT:editText.toggleSubscript();if(editText.isSubscript()){editText.applyScriptSpan(SubscriptSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(SubscriptSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_SUPERSCRIPT:editText.toggleSuperscript();if(editText.isSuperscript()){editText.applyScriptSpan(SuperscriptSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(SuperscriptSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_TODO:richEdit.addTodoLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_DOT:richEdit.addDotLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_NUMERIC:richEdit.addNumericLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_PHOTO:richEdit.addPhotoLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        //case SpanButton.SPAN_TEXTSIZE:editText.changeSize();editText.applyRelativeSpan();break;
        //case SpanButton.SPAN_BOLD:editText.toggleBold();if(editText.isBold()){editText.applyStyleSpan(Typeface.BOLD);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.BOLD);v.setColor(0xff757575);}break;
    }
}
 
Example 20
Project: SpannableStringDemo   File: MainActivity.java   Source Code and License 5 votes vote down vote up
/**
 * 设置上标
 */
private void showSuperscriptSpan()
{
    TextView tvSuperScriptSpan = (TextView) findViewById(R.id.tv_superscript_span);
    SpannableString spannableString = new SpannableString("这是第六行设置文字上标:X2");
    SuperscriptSpan superscriptSpan = new SuperscriptSpan();
    spannableString.setSpan(superscriptSpan,13,14,Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    tvSuperScriptSpan.setText(spannableString);
}
 
Example 21
Project: materialistic   File: StoryView.java   Source Code and License 5 votes vote down vote up
public void setPromoted(int change) {
    SpannableString spannable = new SpannableString(String.format(Locale.US, PROMOTED, change));
    spannable.setSpan(new SuperscriptSpan(), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new RelativeSizeSpan(0.6f), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(mPromotedColorResId), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    mRankTextView.append(spannable);
}
 
Example 22
Project: Loop   File: Transformers.java   Source Code and License 5 votes vote down vote up
@Override
public CharSequence prepare(String item) {
    SpannableString spannableString = new SpannableString("#" + item);
    spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#85F5F5F5")), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(new SuperscriptSpan(), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableString;
}
 
Example 23
Project: Trestle   File: Trestle.java   Source Code and License 5 votes vote down vote up
private static void setUpSuperscriptSpan(Span span, SpannableString ss, int start, int end) {
    if (span.isSuperscript()) {
        ss.setSpan(
            new SuperscriptSpan(),
            start,
            end,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
Example 24
Project: prayer-times-android   File: Utils.java   Source Code and License 5 votes vote down vote up
public static CharSequence fixTimeForHTML(String time) {
    time = fixTime(time);
    if (!Prefs.use12H()) {
        return time;
    }
    int d = time.indexOf(" ");
    if (d < 0) return time;
    time = time.replace(" ", "");

    int s = time.length();
    Spannable span = new SpannableString(time);
    span.setSpan(new SuperscriptSpan(), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    span.setSpan(new RelativeSizeSpan(0.5f), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return span;
}
 
Example 25
Project: hashtag-view   File: Transformers.java   Source Code and License 5 votes vote down vote up
@Override
public CharSequence prepare(String item) {
    SpannableString spannableString = new SpannableString("#" + item);
    spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#85F5F5F5")), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(new SuperscriptSpan(), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableString;
}
 
Example 26
Project: Iolite   File: EighthBlock.java   Source Code and License 5 votes vote down vote up
public Spannable getDisp() {
	// Add postfix
	String str = DATE_FORMAT.format(date);
	if (str.charAt(str.length() - 2) == '1') {
		str += "th";
	} else {
		switch (str.charAt(str.length() - 1)) {
			case '1':
				str += "st";
				break;
			case '2':
				str += "nd";
				break;
			case '3':
				str += "rd";
				break;
			default:
				str += "th";
		}
	}
	// Format postfix into superscript
	Spannable sp = new SpannableString(str);
	sp.setSpan(new SuperscriptSpan(), sp.length() - 2, sp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	sp.setSpan(new RelativeSizeSpan(.75f), sp.length() - 2, sp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

	return sp;
}
 
Example 27
Project: lifeograph-android   File: ActivityEntry.java   Source Code and License 5 votes vote down vote up
private void apply_comment() {
    addSpan( new TextAppearanceSpan( this, R.style.commentSpan ), m_pos_start, pos_current + 1,
             Spanned.SPAN_INTERMEDIATE );

    addSpan( new ForegroundColorSpan( mColorMid ), m_pos_start, pos_current + 1,
             Spanned.SPAN_INTERMEDIATE );

    addSpan( new SuperscriptSpan(), m_pos_start, pos_current + 1, 0 );
}
 
Example 28
Project: Android-Spans   File: Span.java   Source Code and License 4 votes vote down vote up
public static Node superscript(Object... nodes) {
    return new SpanNode(new SuperscriptSpan(), nodes);
}
 
Example 29
Project: mvvm-template   File: SuperScriptHandler.java   Source Code and License 4 votes vote down vote up
@Override public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
    builder.setSpan(new SuperscriptSpan(), start, end, 33);
    builder.setSpan(new RelativeSizeSpan(0.8f), start, end, 33);
}
 
Example 30
Project: SDHtmlTextView   File: SuperScriptHandler.java   Source Code and License 4 votes vote down vote up
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, SpanStack spanStack) {
	spanStack.pushSpan(new SuperscriptSpan(), start, end);
}
 
Example 31
Project: BabushkaText   File: BabushkaText.java   Source Code and License 4 votes vote down vote up
private void applySpannablesTo(Piece aPiece, SpannableString finalString, int start, int end) {

        if(aPiece.subscript) {
            finalString.setSpan(new SubscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.superscript) {
            finalString.setSpan(new SuperscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.strike) {
            finalString.setSpan(new StrikethroughSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.underline) {
            finalString.setSpan(new UnderlineSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        // style
        finalString.setSpan(new StyleSpan(aPiece.style), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // absolute text size
        finalString.setSpan(new AbsoluteSizeSpan(aPiece.textSize), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // relative text size
        finalString.setSpan(new RelativeSizeSpan(aPiece.textSizeRelative), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // text color
        finalString.setSpan(new ForegroundColorSpan(aPiece.textColor), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // background color
        if(aPiece.backgroundColor != -1) {
            finalString.setSpan(new BackgroundColorSpan(aPiece.backgroundColor), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
 
Example 32
Project: HtmlCompat   File: HtmlToSpannedConverter.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        endCssStyle(tag, mSpannableStringBuilder);
        endBlockElement(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("ul")) {
        endBlockElement(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("li")) {
        endLi(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        endBlockElement(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endCssStyle(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("strong")) {
        end(tag, mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("b")) {
        end(tag, mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("em")) {
        end(tag, mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("cite")) {
        end(tag, mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(tag, mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("i")) {
        end(tag, mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("big")) {
        end(tag, mSpannableStringBuilder, Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(tag, mSpannableStringBuilder, Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        endBlockquote(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("tt")) {
        end(tag, mSpannableStringBuilder, Monospace.class, new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(tag, mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("u")) {
        end(tag, mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(tag, mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("s")) {
        end(tag, mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(tag, mSpannableStringBuilder, Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(tag, mSpannableStringBuilder, Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(tag, 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(tag, mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, null, mSpannableStringBuilder, mReader);
    }
}
 
Example 33
Project: E621Mobile   File: DTextRuleCollection.java   Source Code and License 4 votes vote down vote up
@Override
public void apply(Spannable s, TextView tv)
{
	s.setSpan(new SuperscriptSpan(),0,s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
	s.setSpan(new RelativeSizeSpan(0.5f), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
 
Example 34
Project: android-common-util-light   File: StyledText.java   Source Code and License 4 votes vote down vote up
public StyledText appendSuperscript(CharSequence text){
	return append(text, new SuperscriptSpan());
}
 
Example 35
Project: ForPDA   File: Html.java   Source Code and License 4 votes vote down vote up
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);
    } 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.875f));
    } 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);
    }
}
 
Example 36
Project: text-decorator   File: TextDecorator.java   Source Code and License 4 votes vote down vote up
public TextDecorator setSuperscript(final int start, final int end) {
  checkIndexOutOfBoundsException(start, end);
  decoratedContent.setSpan(new SuperscriptSpan(), start, end, flags);

  return this;
}
 
Example 37
Project: locus-addon-wearables   File: SpannableTextUtils.java   Source Code and License 4 votes vote down vote up
public static void addStyledText(SpannableStringBuilder ssb, CharSequence textToAdd,
								 float relativeSize, int typeFace, int color, boolean strike, boolean superScript) {
	// add text to builder
	int startIndex = ssb.length();
	ssb.append(textToAdd);

	// set size
	if (relativeSize != TEXT_DEF_SIZE) {
		ssb.setSpan(new RelativeSizeSpan(relativeSize),
				startIndex, ssb.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	}

	// set color
	if (color != TEXT_DEF_COLOR) {
		ssb.setSpan(new ForegroundColorSpan(color),
				startIndex, ssb.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	}

	// set typeFace
	if (typeFace != TEXT_DEF_TYPEFACE) {
		ssb.setSpan(new StyleSpan(typeFace),
				startIndex, ssb.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	}

	// stroke text also
	if (strike) {
		ssb.setSpan(new StrikethroughSpan(),
				startIndex, ssb.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	}

	// subScript text also
	if (superScript) {
		ssb.setSpan(new SuperscriptSpan(),
				startIndex, ssb.length(),
				Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	}
}
 
Example 38
Project: AndroidSamples   File: SpannableActivity.java   Source Code and License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_spannable);
    ButterKnife.bind(this);

    SpannableString spannableString = new SpannableString("前景色背景色相对大小删除线下划线" +
            "上标小上标下标粗体斜体显示图片点击超链接");

    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.parseColor("#0099EE"));
    BackgroundColorSpan backgroundColorSpan = new BackgroundColorSpan(Color.parseColor("#AC00FF30"));
    RelativeSizeSpan relativeSizeSpan = new RelativeSizeSpan(2f);
    StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
    UnderlineSpan underlineSpan = new UnderlineSpan();
    SuperscriptSpan superscriptSpan = new SuperscriptSpan();
    RelativeSizeSpan relativeSizeSpan2 = new RelativeSizeSpan(0.5f);
    SubscriptSpan subscriptSpan = new SubscriptSpan();
    StyleSpan styleSpan_B = new StyleSpan(Typeface.BOLD);
    StyleSpan styleSpan_I = new StyleSpan(Typeface.ITALIC);

    ImageSpan imageSpan = new ImageSpan(this, R.mipmap.ic_launcher);
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            Toast.makeText(SpannableActivity.this, "点击", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            // 文字不变色
            ds.setUnderlineText(false);
        }
    };
    URLSpan urlSpan = new URLSpan("http://www.sdwfqin.com");

    spannableString.setSpan(foregroundColorSpan, 0, 3, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(backgroundColorSpan, 3, 6, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(relativeSizeSpan, 6, 10, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(strikethroughSpan, 10, 13, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(underlineSpan, 13, 16, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(superscriptSpan, 16, 21, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(relativeSizeSpan2, 18, 21, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(subscriptSpan, 21, 23, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(styleSpan_B, 23, 25, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(styleSpan_I, 25, 27, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(imageSpan, 29, 31, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(clickableSpan, 31, 33, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableString.setSpan(urlSpan, 33, 36, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

    spanString.setMovementMethod(LinkMovementMethod.getInstance());
    // 点击背景色
    // spanString.setHighlightColor(Color.parseColor("#36969696"));
    // 可以点击
    spanString.setText(spannableString);

    SpannableStringBuilder builder = new SpannableStringBuilder("哈哈哈");
    builder.setSpan(foregroundColorSpan, 0, 3, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    builder.append("lalala");
    // 注意:如果使用toString()方法设置的样式就没有了
    spanBuilder.setText(builder);
}
 
Example 39
Project: memoir   File: ConverterHtmlToSpanned.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr();
    } else if (tag.equalsIgnoreCase("p")) {
        handleP();
    } else if (tag.equalsIgnoreCase("div")) {
        endDiv();
    } else if (tag.equalsIgnoreCase("ul")) {
        endList(false);
    } else if (tag.equalsIgnoreCase("ol")) {
        endList(true);
    } else if (tag.equalsIgnoreCase("li")) {
        endList();
    } else if (tag.equalsIgnoreCase("strong")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("b")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("em")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("cite")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("i")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont();
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP();
        end(Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("a")) {
        endAHref();
    } else if (tag.equalsIgnoreCase("u")) {
        end(Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 &&
            Character.toLowerCase(tag.charAt(0)) == 'h' &&
            tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        handleP();
        endHeader();
    } else if (sIgnoreTags.contains(tag.toLowerCase(Locale.getDefault()))) {
        mIgnoreContent = false;
    }
}
 
Example 40
Project: memoir   File: ConverterHtmlToSpanned.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr();
    } else if (tag.equalsIgnoreCase("p")) {
        handleP();
    } else if (tag.equalsIgnoreCase("div")) {
        endDiv();
    } else if (tag.equalsIgnoreCase("ul")) {
        endList(false);
    } else if (tag.equalsIgnoreCase("ol")) {
        endList(true);
    } else if (tag.equalsIgnoreCase("li")) {
        endList();
    } else if (tag.equalsIgnoreCase("strong")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("b")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("em")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("cite")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("i")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont();
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP();
        end(Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("a")) {
        endAHref();
    } else if (tag.equalsIgnoreCase("u")) {
        end(Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 &&
            Character.toLowerCase(tag.charAt(0)) == 'h' &&
            tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        handleP();
        endHeader();
    } else if (sIgnoreTags.contains(tag.toLowerCase(Locale.getDefault()))) {
        mIgnoreContent = false;
    }
}
 
Example 41
Project: typhon   File: SpannableHook.java   Source Code and License 4 votes vote down vote up
@Override
public void endSuperscript() {
    if (superScriptStart != null)
        setSpan(new SuperscriptSpan(), superScriptStart);
    superScriptStart = null;
}
 
Example 42
Project: SimpleText   File: SimpleText.java   Source Code and License 4 votes vote down vote up
public SimpleText superscript() {
  for (Range range : rangeList) {
    setSpan(new SuperscriptSpan(), range.from, range.to, SPAN_MODE);
  }
  return this;
}
 
Example 43
Project: AyoSunny   File: HtmlTagHandler.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(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")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } 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("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);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, null);
    }
}
 
Example 44
Project: AyoSunny   File: HtmlHandler.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(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")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } 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("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);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, null);
    }
}
 
Example 45
Project: Doctor   File: ConverterHtmlToSpanned.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr();
    } else if (tag.equalsIgnoreCase("p")) {
        handleP();
    } else if (tag.equalsIgnoreCase("div")) {
        endDiv();
    } else if (tag.equalsIgnoreCase("ul")) {
        endList(false);
    } else if (tag.equalsIgnoreCase("ol")) {
        endList(true);
    } else if (tag.equalsIgnoreCase("li")) {
        endList();
    } else if (tag.equalsIgnoreCase("strong")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("b")) {
        end(Bold.class, new BoldSpan());
    } else if (tag.equalsIgnoreCase("em")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("cite")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("dfn")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("i")) {
        end(Italic.class, new ItalicSpan());
    } else if (tag.equalsIgnoreCase("strike")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("del")) {
        end(Strikethrough.class, new StrikethroughSpan());
    } else if (tag.equalsIgnoreCase("big")) {
        end(Big.class, new RelativeSizeSpan(1.25f));
    } else if (tag.equalsIgnoreCase("small")) {
        end(Small.class, new RelativeSizeSpan(0.8f));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont();
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP();
        end(Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("a")) {
        endAHref();
    } else if (tag.equalsIgnoreCase("u")) {
        end(Underline.class, new UnderlineSpan());
    } else if (tag.equalsIgnoreCase("sup")) {
        end(Super.class, new SuperscriptSpan());
    } else if (tag.equalsIgnoreCase("sub")) {
        end(Sub.class, new SubscriptSpan());
    } else if (tag.length() == 2 &&
            Character.toLowerCase(tag.charAt(0)) == 'h' &&
            tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
        handleP();
        endHeader();
    } else if (sIgnoreTags.contains(tag.toLowerCase(Locale.getDefault()))) {
        mIgnoreContent = false;
    }
}
 
Example 46
Project: nono-android   File: BaseRichEditText.java   Source Code and License 4 votes vote down vote up
public void removeSpan(Object what,int start,int end) {
    int s = getEditableText().getSpanStart(what);
    int e = getEditableText().getSpanEnd(what);
    getEditableText().removeSpan(what);
    end = end > e ? e : end;
    start = start > s ? start : s;
    if (what instanceof AbsoluteSizeSpan) {
        setSpan(new AbsoluteSizeSpan(
                ((AbsoluteSizeSpan) what).getSize(), false), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new AbsoluteSizeSpan(
                ((AbsoluteSizeSpan) what).getSize(), false), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof RelativeSizeSpan) {
        setSpan(new RelativeSizeSpan(((RelativeSizeSpan) what).getSizeChange()), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new RelativeSizeSpan(((RelativeSizeSpan) what).getSizeChange()), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof StyleSpan) {
        if (((StyleSpan) what).getStyle() == Typeface.BOLD) {
            setSpan(new StyleSpan(Typeface.BOLD), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            setSpan(new StyleSpan(Typeface.BOLD), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else if (((StyleSpan) what).getStyle() == Typeface.ITALIC) {
            setSpan(new StyleSpan(Typeface.ITALIC), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            setSpan(new StyleSpan(Typeface.ITALIC), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    } else if (what instanceof ForegroundColorSpan) {
        setSpan(new ForegroundColorSpan(((ForegroundColorSpan) what).getForegroundColor()), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new ForegroundColorSpan(((ForegroundColorSpan) what).getForegroundColor()), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof BackgroundColorSpan) {
        setSpan(new ForegroundColorSpan(((BackgroundColorSpan) what).getBackgroundColor()), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new ForegroundColorSpan(((BackgroundColorSpan) what).getBackgroundColor()), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof UnderlineSpan) {
        setSpan(new UnderlineSpan(), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new UnderlineSpan(), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof StrikethroughSpan) {
        setSpan(new StrikethroughSpan(), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new StrikethroughSpan(), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof SubscriptSpan) {
        setSpan(new SubscriptSpan(), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new SubscriptSpan(), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else if (what instanceof SuperscriptSpan) {
        setSpan(new SuperscriptSpan(), s, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        setSpan(new SuperscriptSpan(), end, e, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
Example 47
Project: nono-android   File: BaseRichEditText.java   Source Code and License 4 votes vote down vote up
@Override
protected void onSelectionChanged(int selStart, int selEnd) {

    super.onSelectionChanged(selStart, selEnd);
    selStart=selStart<0?0:selStart;
    selEnd=selEnd<0?0:selEnd;
    if(selStart>selEnd) {
        int temp = selEnd;
        selEnd = selStart;
        selStart = temp;
    }
    if(length()==0){
        return;
    }
    isUnderLine = getSelectionSpan(UnderlineSpan.class,selStart,selEnd);
    isStrikethrough = getSelectionSpan(StrikethroughSpan.class,selStart,selEnd);
    isBold = getSelectionSpan(Typeface.BOLD,selStart,selEnd);
    isItalic = getSelectionSpan(Typeface.ITALIC,selStart,selEnd);
    isSubscript = getSelectionSpan(SubscriptSpan.class,selStart,selEnd);
    isSuperscript = getSelectionSpan(SuperscriptSpan.class,selStart,selEnd);
    isForegroundColor = getSelectionSpan(ForegroundColorSpan.class,selStart,selEnd);
    isBackgroundColor=getSelectionSpan(BackgroundColorSpan.class,selStart,selEnd);
    sizeFlag=MEDIUM_TEXT;
    RelativeSizeSpan[] spans;
    if(selStart==selEnd){
        if(selStart>1){
            selStart=selStart-1;
            spans= getEditableText().getSpans(selStart, selStart+1, RelativeSizeSpan.class);
        }else {
            spans = getEditableText().getSpans(selStart, selStart, RelativeSizeSpan.class);
        }
    }else {
        spans= getEditableText().getSpans(selStart, selStart+1, RelativeSizeSpan.class);
    }
    if(spans.length>0){
        float size=spans[0].getSizeChange();
        if(size==textMultiple[SMALL_TEXT]){
            sizeFlag=SMALL_TEXT;
        }else if(size==textMultiple[LARGE_TEXT]){
            sizeFlag=LARGE_TEXT;
        }else {
            sizeFlag=MEDIUM_TEXT;
        }
    }
    if(selectionSpanCallback!=null) {
        selectionSpanCallback.callback(
                isUnderLine,
                isStrikethrough,
                isBold,
                isItalic,
                isSubscript,
                isSuperscript,
                isForegroundColor,
                colorFontForeground,
                isBackgroundColor,
                colorFontBackground,
                sizeFlag);
    }
}
 
Example 48
Project: luxunPro   File: BabushkaText.java   Source Code and License 4 votes vote down vote up
private void applySpannablesTo(Piece aPiece, SpannableString finalString, int start, int end) {

        if(aPiece.subscript) {
            finalString.setSpan(new SubscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.superscript) {
            finalString.setSpan(new SuperscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.strike) {
            finalString.setSpan(new StrikethroughSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.underline) {
            finalString.setSpan(new UnderlineSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        // style
        finalString.setSpan(new StyleSpan(aPiece.style), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // absolute text size
        finalString.setSpan(new AbsoluteSizeSpan(aPiece.textSize), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // relative text size
        finalString.setSpan(new RelativeSizeSpan(aPiece.textSizeRelative), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // text color
        finalString.setSpan(new ForegroundColorSpan(aPiece.textColor), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // background color
        if(aPiece.backgroundColor != -1) {
            finalString.setSpan(new BackgroundColorSpan(aPiece.backgroundColor), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
 
Example 49
Project: Nimingban   File: Html.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (mTagHandler == null || !mTagHandler.handleTag(false, tag,
            mSpannableStringBuilder, mReader, null)) {
        if (tag.equalsIgnoreCase("br")) {
            handleBr(mSpannableStringBuilder);
        } else if (tag.equalsIgnoreCase("p")) {
            handleP(mSpannableStringBuilder);
        } else if (tag.equalsIgnoreCase("div")) {
            handleP(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")) {
            handleP(mSpannableStringBuilder);
            end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
        } 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("ins")) {
            end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
        } else if (tag.equalsIgnoreCase("strike")) {
            end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
        } else if (tag.equalsIgnoreCase("s")) {
            end(mSpannableStringBuilder, Strike.class, new StrikethroughSpan());
        } else if (tag.equalsIgnoreCase("del")) {
            end(mSpannableStringBuilder, Strike.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') {
            handleP(mSpannableStringBuilder);
            endHeader(mSpannableStringBuilder);
        }
    }
}
 
Example 50
Project: MVPAndroidBootstrap   File: BabushkaText.java   Source Code and License 4 votes vote down vote up
private void applySpannablesTo(Piece aPiece, SpannableString finalString, int start, int end) {

        if(aPiece.subscript) {
            finalString.setSpan(new SubscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.superscript) {
            finalString.setSpan(new SuperscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.strike) {
            finalString.setSpan(new StrikethroughSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.underline) {
            finalString.setSpan(new UnderlineSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        // style
        finalString.setSpan(new StyleSpan(aPiece.style), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // absolute text size
        finalString.setSpan(new AbsoluteSizeSpan(aPiece.textSize), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // relative text size
        finalString.setSpan(new RelativeSizeSpan(aPiece.textSizeRelative), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // text color
        finalString.setSpan(new ForegroundColorSpan(aPiece.textColor), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // background color
        if(aPiece.backgroundColor != -1) {
            finalString.setSpan(new BackgroundColorSpan(aPiece.backgroundColor), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
 
Example 51
Project: wATLlib   File: SpannedSerializator.java   Source Code and License 4 votes vote down vote up
private SpanPlacementInfo readSingleCharacterStyle(DataInputStream dis) throws IOException {
    SpanPlacementInfo spi = new SpanPlacementInfo();
    spi.start = dis.readInt();
    spi.end = dis.readInt();
    spi.mode = dis.readInt();
    int tag = dis.readInt();
    switch (tag) {
        case -1:
            return spi; // we does not known this span type
        case -2: // underlying?
            int ref = dis.readInt();
            spi.span = CharacterStyle.wrap((CharacterStyle) mWrittenTagsReverse.get(ref));
            return spi;
        case 1: // BackgroundColorSpan
            spi.span = new BackgroundColorSpan(dis.readInt());
            break;
        case 3: // ForegroundColorSpan
            spi.span = new ForegroundColorSpan(dis.readInt());
            break;
        case 7: // StrikeTroughSpan
            spi.span = new StrikethroughSpan();
            break;
        case 8: // SuggestionSpan
            Log.w(TAG, "SuggestionSpan not supported");
            break;
        case 9: // UnderlineSpan
            spi.span = new UnderlineSpan();
            break;
        case 10: // AbsoluteSizeSpan
            spi.span = new AbsoluteSizeSpan(dis.readInt(),dis.readBoolean());
            break;
        case 11:
            spi.span = readDynamicDrawableSpan(dis);
            break;
        case 12: // ImageSpan
            spi.span = readImageSpanData(dis);
            break;
        case 13: // LocaleSpan
            // unsupported
            break;
        case 14: // RelativeSizeSpan
            spi.span = new RelativeSizeSpan(dis.readFloat());
            break;
        case 16: // ScaleXSpan
            spi.span = new ScaleXSpan(dis.readFloat());
            break;
        case 17: // StyleSpan
            spi.span = new StyleSpan(dis.readInt());
            break;
        case 18: // SubscriptSpan
            spi.span = new SubscriptSpan();
            break;
        case 19: // SuperscriptSpan
            spi.span = new SuperscriptSpan();
            break;
        case 20: // TextAppearanceSpan
            // spi.span = new TextAppearanceSpan();
            break;
        case 21: // TypefaceSpan
            String fontFamily = dis.readUTF();
            spi.span = new TypefaceSpan(fontFamily);
            break;
        case 22: // UrlSpan
            spi.span = new URLSpan(dis.readUTF());
            break;
        default:
            spi.span = read(tag,dis);
    }
    if (spi.span!=null) {
        mWrittenTagsReverse.put(mWrittenTagsReverse.size(), spi.span);
    }
    return spi;
}
 
Example 52
Project: wordpress_app_android   File: WPHtml.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (post != null) {
        if (!post.isLocalDraft())
            return;
    }
    if (!mysteryTagFound) {
        if (tag.equalsIgnoreCase("br")) {
            handleBr(mSpannableStringBuilder);
        } else if (tag.equalsIgnoreCase("p")) {
            handleP(mSpannableStringBuilder);
        } else if (tag.equalsIgnoreCase("div")) {
            handleP(mSpannableStringBuilder);
        } else if (tag.equalsIgnoreCase("em")) {
            end(mSpannableStringBuilder, Italic.class, new StyleSpan(
                    Typeface.ITALIC));
        } else if (tag.equalsIgnoreCase("b")) {
            end(mSpannableStringBuilder, Bold.class, new StyleSpan(
                    Typeface.BOLD));
        } else if (tag.equalsIgnoreCase("strong")) {
            end(mSpannableStringBuilder, Bold.class, new StyleSpan(
                    Typeface.BOLD));
        } 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")) {
            handleP(mSpannableStringBuilder);
            end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
        } 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 WPUnderlineSpan());
        } 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.equalsIgnoreCase("strike")) {
            end(mSpannableStringBuilder, Strike.class,
                    new StrikethroughSpan());
        } else if (tag.length() == 2
                && Character.toLowerCase(tag.charAt(0)) == 'h'
                && tag.charAt(1) >= '1' && tag.charAt(1) <= '6') {
            handleP(mSpannableStringBuilder);
            endHeader(mSpannableStringBuilder);
        }
    } else {
        if (tag.equalsIgnoreCase("html") || tag.equalsIgnoreCase("body")) {
            return;
        }

        if (mysteryTagName.equals(tag)) {
            mysteryTagFound = false;
            mSpannableStringBuilder.append(mysteryTagContent);
        }
        // mTagHandler.handleTag(false, tag, mSpannableStringBuilder,
        // mReader,
        // mysteryTagContent);
    }
}
 
Example 53
Project: android-customfonthtml   File: CustomHtml.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
	if (tag.equalsIgnoreCase("br")) {
		handleBr(mSpannableStringBuilder);
	} else if (tag.equalsIgnoreCase("p")) {
		handleP(mSpannableStringBuilder);
	} else if (tag.equalsIgnoreCase("div")) {
		handleP(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")) {
		handleP(mSpannableStringBuilder);
		end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
	} 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("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);
		endHeader(mSpannableStringBuilder);
	} else if (mTagHandler != null) {
		mTagHandler.handleTag(false, tag, mSpannableStringBuilder,
				mReader);
	}
}
 
Example 54
Project: soulissapp   File: NotificationPresets.java   Source Code and License 4 votes vote down vote up
public Notification buildStyleNotification(Context context) {
    Notification.Builder builder = buildBasicNotification(context);

    Notification.BigTextStyle style = new Notification.BigTextStyle();

    SpannableStringBuilder title = new SpannableStringBuilder();
    appendStyled(title, "Stylized", new StyleSpan(Typeface.BOLD_ITALIC));
    title.append(" title");
    SpannableStringBuilder text = new SpannableStringBuilder("Stylized text: ");
    appendStyled(text, "C", new ForegroundColorSpan(Color.RED));
    appendStyled(text, "O", new ForegroundColorSpan(Color.GREEN));
    appendStyled(text, "L", new ForegroundColorSpan(Color.BLUE));
    appendStyled(text, "O", new ForegroundColorSpan(Color.YELLOW));
    appendStyled(text, "R", new ForegroundColorSpan(Color.MAGENTA));
    appendStyled(text, "S", new ForegroundColorSpan(Color.CYAN));
    text.append("; ");
    appendStyled(text, "1.25x size", new RelativeSizeSpan(1.25f));
    text.append("; ");
    appendStyled(text, "0.75x size", new RelativeSizeSpan(0.75f));
    text.append("; ");
    appendStyled(text, "underline", new UnderlineSpan());
    text.append("; ");
    appendStyled(text, "strikethrough", new StrikethroughSpan());
    text.append("; ");
    appendStyled(text, "bold", new StyleSpan(Typeface.BOLD));
    text.append("; ");
    appendStyled(text, "italic", new StyleSpan(Typeface.ITALIC));
    text.append("; ");
    appendStyled(text, "sans-serif-thin", new TypefaceSpan("sans-serif-thin"));
    text.append("; ");
    appendStyled(text, "monospace", new TypefaceSpan("monospace"));
    text.append("; ");
    appendStyled(text, "sub", new SubscriptSpan());
    text.append("script");
    appendStyled(text, "super", new SuperscriptSpan());

    style.setBigContentTitle(title);
    style.bigText(text);

    builder.setStyle(style);
    return builder.build();
}
 
Example 55
Project: v2ex-android   File: Html.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(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")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class,
                new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("a")) {
        endA(mSpannableStringBuilder, mImageGetter);
    } 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);
        endHeader(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("script")) {
        endScript(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("iframe")) {
        endIframe(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("button")) {
        endButton(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("code")) {
        end(mSpannableStringBuilder, Code.class, new BackgroundColorSpan(0xFFEEEEEE));
    } else if (tag.equalsIgnoreCase("pre")) {
        mInPreTag = false;
        end(mSpannableStringBuilder, Pre.class, new BackgroundColorSpan(0xFFEEEEEE));
    } else if (tag.equalsIgnoreCase("li")) {
        mSpannableStringBuilder.append('\n');
    }
}
 
Example 56
Project: RxAndroidBootstrap   File: BabushkaText.java   Source Code and License 4 votes vote down vote up
private void applySpannablesTo(Piece aPiece, SpannableString finalString, int start, int end) {

        if(aPiece.subscript) {
            finalString.setSpan(new SubscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.superscript) {
            finalString.setSpan(new SuperscriptSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.strike) {
            finalString.setSpan(new StrikethroughSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        if(aPiece.underline) {
            finalString.setSpan(new UnderlineSpan(), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        // style
        finalString.setSpan(new StyleSpan(aPiece.style), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // absolute text size
        finalString.setSpan(new AbsoluteSizeSpan(aPiece.textSize), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // relative text size
        finalString.setSpan(new RelativeSizeSpan(aPiece.textSizeRelative), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // text color
        finalString.setSpan(new ForegroundColorSpan(aPiece.textColor), start, end,
                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        // background color
        if(aPiece.backgroundColor != -1) {
            finalString.setSpan(new BackgroundColorSpan(aPiece.backgroundColor), start, end,
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
 
Example 57
Project: love   File: Html.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
	if (tag.equalsIgnoreCase("br")) {
		handleBr(mSpannableStringBuilder);
	} else if (tag.equalsIgnoreCase("p")) {
		handleP(mSpannableStringBuilder);
	} else if (tag.equalsIgnoreCase("div")) {
		handleP(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")) {
		endEm(mSpannableStringBuilder);
	} 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")) {
		handleP(mSpannableStringBuilder);
		end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
	} 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("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);
		endHeader(mSpannableStringBuilder);
	} else if (mTagHandler != null) {
		mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
	}
}
 
Example 58
Project: shikimori   File: HtmlToSpannedConverter.java   Source Code and License 4 votes vote down vote up
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("div")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("em")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("strong")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } 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")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpanShiki(Color.GRAY));
    } 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("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);
        endHeader(mSpannableStringBuilder);
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
 
Example 59
Project: Overchan-Android   File: HtmlParser.java   Source Code and License 4 votes vote down vote up
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();
    } 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);
    }*/
}
 
Example 60
Project: FanFictionReader   File: HtmlParser.java   Source Code and License 4 votes vote down vote up
/***
 * Handles the tailing tag of every element
 *
 * @param element
 */
private void handleEndTag(Element element) {
	final Attributes attributes = element.attributes();
	if (attributes.hasKey("style"))
		handleCssEnd(attributes.get("style"));

	final String tag = element.tagName();
	switch (tag.toLowerCase()) {
		case "p":
		case "div":
			handleP();
			break;
		case "b":
		case "strong":
			endSpan(new StyleSpan(Typeface.BOLD));
			break;
		case "em":
		case "cite":
		case "dfn":
		case "i":
			endSpan(new StyleSpan(Typeface.ITALIC));
			break;
		case "big":
			endSpan(new RelativeSizeSpan(1.25f));
			break;
		case "small":
			endSpan(new RelativeSizeSpan(0.8f));
			break;
		case "blockquote":
			endSpan(new QuoteSpan());
			handleP();
			break;
		case "tt":
			endSpan(new TypefaceSpan("monospace"));
			break;
		case "u":
			endSpan(new UnderlineSpan());
			break;
		case "sub":
			endSpan(new SubscriptSpan());
			break;
		case "sup":
			endSpan(new SuperscriptSpan());
			break;
		case "a":
			handleLink(element.absUrl("href"));
	}
}