Java 类android.text.style.StrikethroughSpan 实例源码

项目:Delightful-SQLBrite    文件:ItemsAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(android.R.layout.simple_list_item_multiple_choice,
                parent, false);
    }

    TodoItem item = getItem(position);
    CheckedTextView textView = (CheckedTextView) convertView;
    textView.setChecked(item.complete());

    CharSequence description = item.description();
    if (item.complete()) {
        SpannableString spannable = new SpannableString(description);
        spannable.setSpan(new StrikethroughSpan(), 0, description.length(), 0);
        description = spannable;
    }

    textView.setText(description);

    return convertView;
}
项目:Slide-RSS    文件:SpoilerRobotoTextView.java   
private void setStrikethrough(SpannableStringBuilder builder) {
    final int offset = "[[d[".length(); // == "]d]]".length()

    int start = -1;
    int end;

    for (int i = 0; i < builder.length() - 3; i++) {
        if (builder.charAt(i) == '['
                && builder.charAt(i + 1) == '['
                && builder.charAt(i + 2) == 'd'
                && builder.charAt(i + 3) == '[') {
            start = i + offset;
        } else if (builder.charAt(i) == ']'
                && builder.charAt(i + 1) == 'd'
                && builder.charAt(i + 2) == ']'
                && builder.charAt(i + 3) == ']') {
            end = i;
            builder.setSpan(new StrikethroughSpan(), start, end,
                    Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            builder.delete(end, end + offset);
            builder.delete(start - offset, start);
            i -= offset + (end - start); // length of text
        }
    }
}
项目:OSchina_resources_android    文件:RichEditText.java   
/**
 * 中横线,即删除线
 *
 * @param isMidLine isMidLine
 */
void setMidLine(boolean isMidLine) {
    int index = getSelectionIndex();
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setMidLine(isMidLine);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isMidLine) {
        edit.setSpan(new StrikethroughSpan(),
                star,
                end,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        StrikethroughSpan[] styleSpans = edit.getSpans(star,
                end, StrikethroughSpan.class);
        for (StrikethroughSpan span : styleSpans) {
            edit.removeSpan(span);
        }
    }
}
项目:OSchina_resources_android    文件:RichEditText.java   
/**
 * 中横线,即删除线
 *
 * @param isMidLine isMidLine
 */
void setMidLine(boolean isMidLine, int index) {
    if (index >= 0 && index < mSections.size()) {
        mSections.get(index).setMidLine(isMidLine);
    }
    Editable edit = getEditableText();
    int star = getSectionStart();
    int end = getSectionEnd();
    if (isMidLine) {
        edit.setSpan(new StrikethroughSpan(),
                star,
                end,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        StrikethroughSpan[] styleSpans = edit.getSpans(star,
                end, StrikethroughSpan.class);
        for (StrikethroughSpan span : styleSpans) {
            edit.removeSpan(span);
        }
    }
}
项目:HtmlCompat    文件:HtmlToSpannedConverter.java   
private void endCssStyle(String tag, Editable text) {
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(tag, text, s, new StrikethroughSpan());
    }
    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(tag, text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }
    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(tag, text, f, new ForegroundColorSpan(f.mForegroundColor));
    }
    AbsoluteSize a = getLast(text, AbsoluteSize.class);
    if (a != null) {
        setSpanFromMark(tag, text, a, new AbsoluteSizeSpan(a.getTextSize()));
    }
    RelativeSize r = getLast(text, RelativeSize.class);
    if (r != null) {
        setSpanFromMark(tag, text, r, new RelativeSizeSpan(r.getTextProportion()));
    }
}
项目:sqlbrite-sqlcipher    文件:ItemsAdapter.java   
@Override public View getView(int position, View convertView, ViewGroup parent) {
  if (convertView == null) {
    convertView = inflater.inflate(android.R.layout.simple_list_item_multiple_choice, parent, false);
  }

  TodoItem item = getItem(position);
  CheckedTextView textView = (CheckedTextView) convertView;
  textView.setChecked(item.complete());

  CharSequence description = item.description();
  if (item.complete()) {
    SpannableString spannable = new SpannableString(description);
    spannable.setSpan(new StrikethroughSpan(), 0, description.length(), 0);
    description = spannable;
  }

  textView.setText(description);

  return convertView;
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:RNLearn_Project1    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:instantsearch-android-examples    文件:PriceView.java   
@SuppressLint("SetTextI18n") /* This will only display US prices */
@Override
public void onUpdateView(JSONObject result) {
    try {
        double salePrice = result.getDouble("salePrice");
        double promoPrice = result.getDouble("promoPrice");
        double lowestPrice = Math.min(salePrice, promoPrice);

        final String priceText = SYMBOL_MONEY + lowestPrice;
        final SpannableStringBuilder finalText = new SpannableStringBuilder(priceText);

        finalText.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.colorPrice)), 0, priceText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        finalText.setSpan(new StyleSpan(Typeface.BOLD), 0, priceText.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

        if (salePrice != promoPrice) {
            finalText.append(" ").append(SYMBOL_MONEY).append(Double.toString(salePrice));
            finalText.setSpan(new StrikethroughSpan(), priceText.length() + 1, finalText.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
        }
        setText(finalText, BufferType.SPANNABLE);
    } catch (JSONException e) {
        Toast.makeText(context, "Error parsing result:" + e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}
项目:Delightful-SQLBrite    文件:ItemsAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(android.R.layout.simple_list_item_multiple_choice,
                parent, false);
    }

    TodoItem item = getItem(position);
    CheckedTextView textView = (CheckedTextView) convertView;
    textView.setChecked(item.complete());

    CharSequence description = item.description();
    if (item.complete()) {
        SpannableString spannable = new SpannableString(description);
        spannable.setSpan(new StrikethroughSpan(), 0, description.length(), 0);
        description = spannable;
    }

    textView.setText(description);

    return convertView;
}
项目:FloatText    文件:ListViewAdapter.java   
private void TextReshow(int index, App utils, ViewHolder view, boolean show, String listtext) {
    FloatTextUtils textutils = utils.getTextutil();
    if (!show) {
        SpannableString str = new SpannableString(listtext);
        str.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        view.textView.setText(str);
    } else {
        view.textView.setText(listtext);
    }
    if (typeface != null) {
        view.textView.setTypeface(typeface);
    }
    if (textutils.getTextShadow().get(index)) {
        view.textView.setShadowLayer(textutils.getTextShadowRadius().get(index), textutils.getTextShadowX().get(index), textutils.getTextShadowY().get(index), textutils.getTextShadowColor().get(index));
    } else {
        view.textView.setShadowLayer(0, 0, 0, 0);
    }
    view.textView.getPaint().setFakeBoldText(utils.getTextutil().getThickShow().get(index));
    view.textView.setTextColor(utils.getTextutil().getColorShow().get(index));
    view.textView.setEllipsize(TextUtils.TruncateAt.END);
}
项目:ForPDA    文件:Html.java   
private static void endCssStyle(Editable text) {
    Font font = getLast(text, Font.class);
    if (font != null) {
        if (font.mFace.equalsIgnoreCase("fontello")) {
            setSpanFromMark(text, font, new AssetsTypefaceSpan(App.getContext(), "fontello/fontello.ttf"));
        }
    }
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(text, s, new StrikethroughSpan());
    }
    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }
    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(text, f, new ForegroundColorSpan(f.mForegroundColor));
    }

}
项目:react-native-box-loaders    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
项目:react-native-box-loaders    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:react-native-box-loaders    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:azure-mobile-engagement-app-android    文件:ProductDiscountActivity.java   
/**
 * Method that adds or removes a strike from a TextView object
 *
 * @param textView The textView to manage
 */
private final void addOrRemoveStrikeTextView(TextView textView, boolean toAdd)
{
  textView.setText(textView.getText().toString(), TextView.BufferType.SPANNABLE);
  final Spannable spannable = (Spannable) textView.getText();

  if (toAdd == true)
  {
    // Add a StrikethroughSpan style
    final StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
    spannable.setSpan(strikethroughSpan, 0, textView.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  }
  else
  {
    // Remove only StrikethroughSpan style
    final Object spans[] = spannable.getSpans(0, textView.length(), Object.class);
    for (final Object span : spans)
    {
      if (span instanceof StrikethroughSpan == true)
      {
        spannable.removeSpan(span);
        return;
      }
    }
  }
}
项目:Ironman    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
项目:Ironman    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:Ironman    文件:ReactTextTest.java   
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
项目:memoir    文件:ConverterSpannedToHtml.java   
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>");
    }
}
项目:memoir    文件:ConverterSpannedToHtml.java   
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>");
    }
}
项目:Type    文件:KnifeText.java   
private void strikethroughInvalid(int start, int end) {
    if (start >= end) {
        return;
    }

    StrikethroughSpan[] spans = getEditableText().getSpans(start, end, StrikethroughSpan.class);
    List<KnifePart> list = new ArrayList<>();

    for (StrikethroughSpan span : spans) {
        list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span)));
        getEditableText().removeSpan(span);
    }

    for (KnifePart part : list) {
        if (part.isValid()) {
            if (part.getStart() < start) {
                strikethroughValid(part.getStart(), start);
            }

            if (part.getEnd() > end) {
                strikethroughValid(end, part.getEnd());
            }
        }
    }
}
项目:Type    文件:KnifeText.java   
private boolean containStrikethrough(int start, int end) {
    if (start > end) {
        return false;
    }

    if (start == end) {
        if (start - 1 < 0 || start + 1 > getEditableText().length()) {
            return false;
        } else {
            StrikethroughSpan[] before = getEditableText().getSpans(start - 1, start, StrikethroughSpan.class);
            StrikethroughSpan[] after = getEditableText().getSpans(start, start + 1, StrikethroughSpan.class);
            return before.length > 0 && after.length > 0;
        }
    } else {
        StringBuilder builder = new StringBuilder();

        for (int i = start; i < end; i++) {
            if (getEditableText().getSpans(i, i + 1, StrikethroughSpan.class).length > 0) {
                builder.append(getEditableText().subSequence(i, i + 1).toString());
            }
        }

        return getEditableText().subSequence(start, end).toString().equals(builder.toString());
    }
}
项目:S1-Next    文件:HtmlTagHandlerCompat.java   
public void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("ul")) {
        endBlockElement(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("li")) {
        endLi(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("span")) {
        endCssStyle(mSpannableStringBuilder);
    } 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 (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
项目:S1-Next    文件:HtmlTagHandlerCompat.java   
private static void endCssStyle(Editable text) {
    Strikethrough s = getLast(text, Strikethrough.class);
    if (s != null) {
        setSpanFromMark(text, s, new StrikethroughSpan());
    }

    Background b = getLast(text, Background.class);
    if (b != null) {
        setSpanFromMark(text, b, new BackgroundColorSpan(b.mBackgroundColor));
    }

    Foreground f = getLast(text, Foreground.class);
    if (f != null) {
        setSpanFromMark(text, f, new ForegroundColorSpan(f.mForegroundColor));
    }
}
项目:AndroidStudyDemo    文件:CouponPriceUtil.java   
/**
 * 现金券显示价格样式
 */
public static SpannableString getCashPrice(Context context, double oldPrice, double newPrice) {
    StringBuilder builder = new StringBuilder();
    builder.append(handleDouble(newPrice)).append("元").append(" ").append(handleDouble(oldPrice)).append("元");
    int start = 0;
    int middle = builder.indexOf(" ") + 1;
    int end = builder.length();
    SpannableString string = new SpannableString(builder);
    /*改变文字的大小*/
    string.setSpan(new AbsoluteSizeSpan(sp2px(context, 20)), start, middle, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    string.setSpan(new AbsoluteSizeSpan(sp2px(context, 14)), middle, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    /*给文字设置删除线*/
    string.setSpan(new StrikethroughSpan(), middle, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    /*改变文字的颜色*/
    int textOrange = context.getResources().getColor(android.R.color.holo_red_light);
    int textGray = context.getResources().getColor(android.R.color.darker_gray);
    string.setSpan(new ForegroundColorSpan(textOrange), start, middle, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    string.setSpan(new ForegroundColorSpan(textGray), middle, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return string;
}
项目:Doctor    文件:ConverterSpannedToHtml.java   
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>");
    }
}
项目:materialistic    文件:HackerNewsItem.java   
@Override
public Spannable getDisplayedTime(Context context) {
    if (displayedTime == null) {
        SpannableStringBuilder builder = new SpannableStringBuilder(dead ?
                context.getString(R.string.dead_prefix) + " " : "");
        SpannableString timeSpannable = new SpannableString(
                AppUtils.getAbbreviatedTimeSpan(time * 1000));
        if (deleted) {
            timeSpannable.setSpan(new StrikethroughSpan(), 0, timeSpannable.length(),
                    Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        }
        builder.append(timeSpannable);
        displayedTime = builder;
    }
    return displayedTime;
}
项目:FMTech    文件:idd.java   
public final void a(SpannableStringBuilder paramSpannableStringBuilder, int paramInt, qpa paramqpa)
{
  boolean bool1 = paramqpa.p().a;
  boolean bool2 = paramqpa.p().b;
  boolean bool3 = paramqpa.p().c;
  int i = paramSpannableStringBuilder.length();
  if ((bool1) && (bool2)) {
    paramSpannableStringBuilder.setSpan(new StyleSpan(3), paramInt, i, 33);
  }
  for (;;)
  {
    if (bool3) {
      paramSpannableStringBuilder.setSpan(new StrikethroughSpan(), paramInt, i, 33);
    }
    return;
    if (bool1) {
      paramSpannableStringBuilder.setSpan(new StyleSpan(1), paramInt, i, 33);
    } else if (bool2) {
      paramSpannableStringBuilder.setSpan(new StyleSpan(2), paramInt, i, 33);
    }
  }
}
项目:FMTech    文件:lwi.java   
public final void handleTag(boolean paramBoolean, String paramString, Editable paramEditable, XMLReader paramXMLReader)
{
  String str = paramString.toLowerCase();
  if ((TextUtils.equals(str, "strike")) || (TextUtils.equals(str, "s")))
  {
    if (paramBoolean)
    {
      int i = paramEditable.length();
      paramEditable.setSpan(new StrikethroughSpan(), i, i, 17);
    }
  }
  else {
    return;
  }
  a(paramEditable);
}
项目:FMTech    文件:hfx.java   
public final void a(SpannableStringBuilder paramSpannableStringBuilder, int paramInt, qop paramqop)
{
  boolean bool1 = efj.b(paramqop.c.a);
  boolean bool2 = efj.b(paramqop.c.b);
  boolean bool3 = efj.b(paramqop.c.c);
  int i = paramSpannableStringBuilder.length();
  if ((bool1) && (bool2)) {
    paramSpannableStringBuilder.setSpan(new StyleSpan(3), paramInt, i, 33);
  }
  for (;;)
  {
    if (bool3) {
      paramSpannableStringBuilder.setSpan(new StrikethroughSpan(), paramInt, i, 33);
    }
    return;
    if (bool1) {
      paramSpannableStringBuilder.setSpan(new StyleSpan(1), paramInt, i, 33);
    } else if (bool2) {
      paramSpannableStringBuilder.setSpan(new StyleSpan(2), paramInt, i, 33);
    }
  }
}
项目:Android-RTEditor    文件:ConverterSpannedToHtml.java   
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>");
    }
}
项目:Knife    文件:KnifeText.java   
protected void strikethroughInvalid(int start, int end) {
    if (start >= end) {
        return;
    }

    StrikethroughSpan[] spans = getEditableText().getSpans(start, end, StrikethroughSpan.class);
    List<KnifePart> list = new ArrayList<>();

    for (StrikethroughSpan span : spans) {
        list.add(new KnifePart(getEditableText().getSpanStart(span), getEditableText().getSpanEnd(span)));
        getEditableText().removeSpan(span);
    }

    for (KnifePart part : list) {
        if (part.isValid()) {
            if (part.getStart() < start) {
                strikethroughValid(part.getStart(), start);
            }

            if (part.getEnd() > end) {
                strikethroughValid(end, part.getEnd());
            }
        }
    }
}
项目:Knife    文件:KnifeText.java   
protected boolean containStrikethrough(int start, int end) {
    if (start > end) {
        return false;
    }

    if (start == end) {
        if (start - 1 < 0 || start + 1 > getEditableText().length()) {
            return false;
        } else {
            StrikethroughSpan[] before = getEditableText().getSpans(start - 1, start, StrikethroughSpan.class);
            StrikethroughSpan[] after = getEditableText().getSpans(start, start + 1, StrikethroughSpan.class);
            return before.length > 0 && after.length > 0;
        }
    } else {
        StringBuilder builder = new StringBuilder();

        for (int i = start; i < end; i++) {
            if (getEditableText().getSpans(i, i + 1, StrikethroughSpan.class).length > 0) {
                builder.append(getEditableText().subSequence(i, i + 1).toString());
            }
        }

        return getEditableText().subSequence(start, end).toString().equals(builder.toString());
    }
}
项目:Knife    文件:KnifeTagHandler.java   
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
    if (opening) {
        if (tag.equalsIgnoreCase(BULLET_LI)) {
            if (output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
                output.append("\n");
            }
            start(output, new Li());
        } else if (tag.equalsIgnoreCase(STRIKETHROUGH_S) || tag.equalsIgnoreCase(STRIKETHROUGH_STRIKE) || tag.equalsIgnoreCase(STRIKETHROUGH_DEL)) {
            start(output, new Strike());
        }
    } else {
        if (tag.equalsIgnoreCase(BULLET_LI)) {
            if (output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
                output.append("\n");
            }
            end(output, Li.class, new BulletSpan());
        } else if (tag.equalsIgnoreCase(STRIKETHROUGH_S) || tag.equalsIgnoreCase(STRIKETHROUGH_STRIKE) || tag.equalsIgnoreCase(STRIKETHROUGH_DEL)) {
            end(output, Strike.class, new StrikethroughSpan());
        }
    }
}
项目:Slide    文件:SpoilerRobotoTextView.java   
private void setStrikethrough(SpannableStringBuilder builder) {
    final int offset = "[[d[".length(); // == "]d]]".length()

    int start = -1;
    int end;

    for (int i = 0; i < builder.length() - 3; i++) {
        if (builder.charAt(i) == '['
                && builder.charAt(i + 1) == '['
                && builder.charAt(i + 2) == 'd'
                && builder.charAt(i + 3) == '[') {
            start = i + offset;
        } else if (builder.charAt(i) == ']'
                && builder.charAt(i + 1) == 'd'
                && builder.charAt(i + 2) == ']'
                && builder.charAt(i + 3) == ']') {
            end = i;
            builder.setSpan(new StrikethroughSpan(), start, end,
                    Spanned.SPAN_INCLUSIVE_INCLUSIVE);
            builder.delete(end, end + offset);
            builder.delete(start - offset, start);
            i -= offset + (end - start); // length of text
        }
    }
}