当前位置: 首页>>代码示例>>Java>>正文


Java QuoteSpan类代码示例

本文整理汇总了Java中android.text.style.QuoteSpan的典型用法代码示例。如果您正苦于以下问题:Java QuoteSpan类的具体用法?Java QuoteSpan怎么用?Java QuoteSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QuoteSpan类属于android.text.style包,在下文中一共展示了QuoteSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceQuoteSpans

import android.text.style.QuoteSpan; //导入依赖的package包/类
/**
 * Replaces the blue line produced by <blockquote>s with something more visible
 *
 * @param spannable parsed comment text #fromHtml
 */
private void replaceQuoteSpans(Spannable spannable) {
    QuoteSpan[] quoteSpans = spannable.getSpans(0, spannable.length(), QuoteSpan.class);

    for (QuoteSpan quoteSpan : quoteSpans) {
        final int start = spannable.getSpanStart(quoteSpan);
        final int end = spannable.getSpanEnd(quoteSpan);
        final int flags = spannable.getSpanFlags(quoteSpan);

        spannable.removeSpan(quoteSpan);

        //If the theme is Light or Sepia, use a darker blue; otherwise, use a lighter blue
        final int barColor =
                (SettingValues.currentTheme == 1 || SettingValues.currentTheme == 5)
                        ? ContextCompat.getColor(getContext(), R.color.md_blue_600)
                        : ContextCompat.getColor(getContext(), R.color.md_blue_400);

        final int BAR_WIDTH = 4;
        final int GAP = 5;

        spannable.setSpan(new CustomQuoteSpan(Color.TRANSPARENT, //background color
                        barColor, //bar color
                        BAR_WIDTH, //bar width
                        GAP), //bar + text gap
                start, end, flags);
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:32,代码来源:SpoilerRobotoTextView.java

示例2: handleEndTag

import android.text.style.QuoteSpan; //导入依赖的package包/类
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } 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("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:24,代码来源:Html.java

示例3: fromHtml

import android.text.style.QuoteSpan; //导入依赖的package包/类
/**
 * an alternative to Html.fromHtml() supporting <ul>, <ol>, <blockquote> tags and replacing EmoticonsUtils with Emojis
 */
public static SpannableStringBuilder fromHtml(String source, WPImageGetter wpImageGetter) {
    SpannableStringBuilder html;
    try {
        html = (SpannableStringBuilder) Html.fromHtml(source, wpImageGetter, new WPHtmlTagHandler());
    } catch (RuntimeException runtimeException) {
        // In case our tag handler fails
        html = (SpannableStringBuilder) Html.fromHtml(source, wpImageGetter, null);
    }
    EmoticonsUtils.replaceEmoticonsWithEmoji(html);
    QuoteSpan spans[] = html.getSpans(0, html.length(), QuoteSpan.class);
    for (QuoteSpan span : spans) {
        html.setSpan(new WPQuoteSpan(), html.getSpanStart(span), html.getSpanEnd(span), html.getSpanFlags(span));
        html.setSpan(new ForegroundColorSpan(0xFF666666), html.getSpanStart(span), html.getSpanEnd(span),
                html.getSpanFlags(span));
        html.removeSpan(span);
    }
    return html;
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:22,代码来源:HtmlUtils.java

示例4: endBlockquote

import android.text.style.QuoteSpan; //导入依赖的package包/类
private static void endBlockquote(SpannableStringBuilder text, ThemeColors colors) {
    int len = text.length();
    Object obj = getLast(text, Blockquote.class);
    int where = text.getSpanStart(obj);
    text.removeSpan(obj);
    
    if (where != len) {
        Blockquote b = (Blockquote) obj;
        if (b.mIsUnkfunc) {
            if (colors != null) {
                text.setSpan(new ForegroundColorSpan(colors.quoteForeground), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        } else {
            text.setSpan(new QuoteSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
 
开发者ID:miku-nyan,项目名称:Overchan-Android,代码行数:18,代码来源:HtmlParser.java

示例5: containQuote

import android.text.style.QuoteSpan; //导入依赖的package包/类
protected boolean containQuote(int index) {
    String[] lines = TextUtils.split(getEditableText().toString(), "\n");
    if (index < 0 || index >= lines.length) {
        return false;
    }

    int start = 0;
    for (int i = 0; i < index; i++) {
        start = start + lines[i].length() + 1;
    }

    int end = start + lines[index].length();
    if (start >= end) {
        return false;
    }

    QuoteSpan[] spans = getEditableText().getSpans(start, end, QuoteSpan.class);
    return spans.length > 0;
}
 
开发者ID:mthli,项目名称:Knife,代码行数:20,代码来源:KnifeText.java

示例6: quote

import android.text.style.QuoteSpan; //导入依赖的package包/类
public TextDecorator quote(final String... texts) {
  int index;

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

  return this;
}
 
开发者ID:nntuyen,项目名称:text-decorator,代码行数:13,代码来源:TextDecorator.java

示例7: testBlockQuote

import android.text.style.QuoteSpan; //导入依赖的package包/类
@Test
public void testBlockQuote() throws Exception {
    String content = "> blockquote\n" +
            "still blockquote";
    Spanned result = Markdown.fromMarkdown(content);
    printSpans(result);
    Object[] spans = result.getSpans(0, result.length(), Object.class);
    assertEquals(1, spans.length);
    assertEquals(QuoteSpan.class, spans[0].getClass());
}
 
开发者ID:Stocard,项目名称:markdown-to-spanned,代码行数:11,代码来源:SpanTests.java

示例8: quota

import android.text.style.QuoteSpan; //导入依赖的package包/类
@Override
public SpannableStringBuilder quota(CharSequence charSequence) {
    SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(charSequence);
    QuoteSpan span = new MarkDownQuoteSpan(quota_color);
    spannableStringBuilder.setSpan(span, 0, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannableStringBuilder.setSpan(new ForegroundColorSpan(quota_text_color), 0, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableStringBuilder;
}
 
开发者ID:zzhoujay,项目名称:Markdown,代码行数:9,代码来源:StyleBuilderImpl.java

示例9: writeSingleParagraphStyle

import android.text.style.QuoteSpan; //导入依赖的package包/类
private void writeSingleParagraphStyle(ParagraphStyle style, DataOutputStream dos) throws IOException {
    Class clazz = style.getClass();
    dos.writeInt(mString.getSpanStart(style));
    dos.writeInt(mString.getSpanEnd(style));
    dos.writeInt(mString.getSpanFlags(style));
    if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) {
        int tag = mCharacterStylesTags.get(clazz.getSimpleName());
        if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) {
            dos.writeInt(tag);
        }
        switch (tag) {
            case 24: // AligmentSpan.Standard
                AlignmentSpan.Standard as2 = (AlignmentSpan.Standard)style;
                dos.writeInt(as2.getAlignment().ordinal());
                break;
            case 25: // BulletSpan
                BulletSpan bs = (BulletSpan)style;
                dos.writeInt(bs.getLeadingMargin(true));
                dos.writeInt(bs.getLeadingMargin(false));

                break;
            case 30: // LeadingMarginSpan.Sandard
                LeadingMarginSpan.Standard lms = (LeadingMarginSpan.Standard)style;
                dos.writeInt(lms.getLeadingMargin(true));
                dos.writeInt(lms.getLeadingMargin(false));
                break;
            case 34: // QuoteSpan
                QuoteSpan qs = (QuoteSpan)style;
                dos.writeInt(qs.getColor());
                break;
            case 36: // TabStopSpan.Standard
                TabStopSpan.Standard tss = (TabStopSpan.Standard)style;
                dos.writeInt(tss.getTabStop());
                break;
            default:
        }
    } else {
        write(style,dos);
    }
}
 
开发者ID:suwhs,项目名称:wATLlib,代码行数:41,代码来源:SpannedSerializator.java

示例10: readSingleParagraph

import android.text.style.QuoteSpan; //导入依赖的package包/类
private SpanPlacementInfo readSingleParagraph(DataInputStream dis) throws IOException {
    SpanPlacementInfo spi = new SpanPlacementInfo();
    spi.start = dis.readInt();
    spi.end = dis.readInt();
    spi.mode = dis.readInt();
    int tag = dis.readInt(); // mCharacterStylesTags.get(clazz.getSimpleName());
    switch (tag) {
        case 24: // AligmentSpan.Standard
            spi.span = new AlignmentSpan.Standard(Alignment.values()[dis.readInt()]);
            break;
        case 25: // BulletSpan
            spi.span = new BulletSpan(dis.readInt());
            dis.readInt(); // skip gap width for other lines
            break;
        case 30: // LeadingMarginSpan.Sandard
            spi.span = new LeadingMarginSpan.Standard(dis.readInt(),dis.readInt());
            break;
        case 34: // QuoteSpan
            spi.span = new QuoteSpan(dis.readInt());
            break;
        case 36: // TabStopSpan.Standard
            spi.span = new TabStopSpan.Standard(dis.readInt());
            break;
        case 80: // RemoteDrawableSpan
            break;
        default:
            spi.span = read(tag,dis);
    }
    return spi;
}
 
开发者ID:suwhs,项目名称:wATLlib,代码行数:31,代码来源:SpannedSerializator.java

示例11: onSelectionChanged

import android.text.style.QuoteSpan; //导入依赖的package包/类
@Override
public void onSelectionChanged() {
    if (!mIsLocalDraft) {
        return;
    }

    final Spannable s = mContentEditText.getText();
    if (s == null)
        return;
    // set toggle buttons if cursor is inside of a matching span
    mStyleStart = mContentEditText.getSelectionStart();
    Object[] spans = s.getSpans(mContentEditText.getSelectionStart(), mContentEditText.getSelectionStart(), Object.class);

    mBoldToggleButton.setChecked(false);
    mEmToggleButton.setChecked(false);
    mBquoteToggleButton.setChecked(false);
    mUnderlineToggleButton.setChecked(false);
    mStrikeToggleButton.setChecked(false);
    for (Object span : spans) {
        if (span instanceof StyleSpan) {
            StyleSpan ss = (StyleSpan) span;
            if (ss.getStyle() == android.graphics.Typeface.BOLD) {
                mBoldToggleButton.setChecked(true);
            }
            if (ss.getStyle() == android.graphics.Typeface.ITALIC) {
                mEmToggleButton.setChecked(true);
            }
        }
        if (span instanceof QuoteSpan) {
            mBquoteToggleButton.setChecked(true);
        }
        if (span instanceof WPUnderlineSpan) {
            mUnderlineToggleButton.setChecked(true);
        }
        if (span instanceof StrikethroughSpan) {
            mStrikeToggleButton.setChecked(true);
        }
    }
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:40,代码来源:LegacyEditorFragment.java

示例12: testNestSpan_order_as_begin

import android.text.style.QuoteSpan; //导入依赖的package包/类
public void testNestSpan_order_as_begin() {
  SpannableStringBuilder result = (SpannableStringBuilder) KmarkProcessor.process(getContext(),
      "> *Sample* text");
  Object[] spans = result.getSpans(0, result.length(), Object.class);
  assertEquals(QuoteSpan.class, spans[0].getClass());
  assertEquals(StyleSpan.class, spans[1].getClass());
}
 
开发者ID:kaif-open,项目名称:kaif-android,代码行数:8,代码来源:KmarkProcessorTest.java

示例13: setUpQuoteSpan

import android.text.style.QuoteSpan; //导入依赖的package包/类
private static void setUpQuoteSpan(Span span, SpannableString ss, int start, int end) {
    int quoteColor = span.getQuoteColor();
    if (quoteColor != 0) {
        ss.setSpan(
            new QuoteSpan(quoteColor),
            start,
            end,
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}
 
开发者ID:lawloretienne,项目名称:Trestle,代码行数:11,代码来源:Trestle.java

示例14: quoteInvalid

import android.text.style.QuoteSpan; //导入依赖的package包/类
protected void quoteInvalid() {
    String[] lines = TextUtils.split(getEditableText().toString(), "\n");

    for (int i = 0; i < lines.length; i++) {
        if (!containQuote(i)) {
            continue;
        }

        int lineStart = 0;
        for (int j = 0; j < i; j++) {
            lineStart = lineStart + lines[j].length() + 1;
        }

        int lineEnd = lineStart + lines[i].length();
        if (lineStart >= lineEnd) {
            continue;
        }

        int quoteStart = 0;
        int quoteEnd = 0;
        if (lineStart <= getSelectionStart() && getSelectionEnd() <= lineEnd) {
            quoteStart = lineStart;
            quoteEnd = lineEnd;
        } else if (getSelectionStart() <= lineStart && lineEnd <= getSelectionEnd()) {
            quoteStart = lineStart;
            quoteEnd = lineEnd;
        }

        if (quoteStart < quoteEnd) {
            QuoteSpan[] spans = getEditableText().getSpans(quoteStart, quoteEnd, QuoteSpan.class);
            for (QuoteSpan span : spans) {
                getEditableText().removeSpan(span);
            }
        }
    }
}
 
开发者ID:mthli,项目名称:Knife,代码行数:37,代码来源:KnifeText.java

示例15: withinHtml

import android.text.style.QuoteSpan; //导入依赖的package包/类
private static void withinHtml(StringBuilder out, Spanned text) {
    int next;

    for (int i = 0; i < text.length(); i = next) {
        next = text.nextSpanTransition(i, text.length(), ParagraphStyle.class);

        ParagraphStyle[] styles = text.getSpans(i, next, ParagraphStyle.class);
        if (styles.length == 2) {
            if (styles[0] instanceof BulletSpan && styles[1] instanceof QuoteSpan) {
                // Let a <br> follow the BulletSpan or QuoteSpan end, so next++
                withinBulletThenQuote(out, text, i, next++);
            } else if (styles[0] instanceof QuoteSpan && styles[1] instanceof BulletSpan) {
                withinQuoteThenBullet(out, text, i, next++);
            } else {
                withinContent(out, text, i, next);
            }
        } else if (styles.length == 1) {
            if (styles[0] instanceof BulletSpan) {
                withinBullet(out, text, i, next++);
            } else if (styles[0] instanceof QuoteSpan) {
                withinQuote(out, text, i, next++);
            } else {
                withinContent(out, text, i, next);
            }
        } else {
            withinContent(out, text, i, next);
        }
    }
}
 
开发者ID:mthli,项目名称:Knife,代码行数:30,代码来源:KnifeParser.java


注:本文中的android.text.style.QuoteSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。