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


Java BulletSpan类代码示例

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


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

示例1: getReplaces

import android.text.style.BulletSpan; //导入依赖的package包/类
@Override
protected Object[] getReplaces(final Editable text, final int indentation) {
    // Nested BulletSpans increases distance between BULLET_SPAN and text, so we must prevent it.
    int bulletMargin = INDENT_PX;
    if (indentation > 1) {
        bulletMargin = INDENT_PX - BULLET_SPAN.getLeadingMargin(true);
        if (indentation > 2) {
            // This get's more complicated when we add a LeadingMarginSpan into the same line:
            // we have also counter it's effect to BulletSpan
            bulletMargin -= (indentation - 2) * LIST_ITEM_INDENT_PX;
        }
    }
    return new Object[]{
            new LeadingMarginSpan.Standard(LIST_ITEM_INDENT_PX * (indentation - 1)),
            new BulletSpan(bulletMargin)
    };
}
 
开发者ID:Stocard,项目名称:markdown-to-spanned,代码行数:18,代码来源:HTMLTagHandler.java

示例2: testSubList

import android.text.style.BulletSpan; //导入依赖的package包/类
@Test
public void testSubList() throws Exception {
    String content = "* item 1\n" +
            "* item 2\n" +
            "    * sublist item 1\n" +
            "    * sublist item 2\n";
    Spanned result = Markdown.fromMarkdown(content);
    printSpans(result);
    Object[] spans = result.getSpans(0, result.length(), Object.class);
    assertEquals(8, spans.length);
    assertEquals(LeadingMarginSpan.Standard.class, spans[0].getClass());
    assertEquals(BulletSpan.class, spans[1].getClass());
    assertEquals(LeadingMarginSpan.Standard.class, spans[2].getClass());
    assertEquals(BulletSpan.class, spans[3].getClass());
    assertEquals(LeadingMarginSpan.Standard.class, spans[4].getClass());
    assertEquals(BulletSpan.class, spans[5].getClass());
    assertEquals(LeadingMarginSpan.Standard.class, spans[6].getClass());
    assertEquals(BulletSpan.class, spans[7].getClass());
}
 
开发者ID:Stocard,项目名称:markdown-to-spanned,代码行数:20,代码来源:SpanTests.java

示例3: containBullet

import android.text.style.BulletSpan; //导入依赖的package包/类
protected boolean containBullet(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;
    }

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

示例4: handleTag

import android.text.style.BulletSpan; //导入依赖的package包/类
@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());
        }
    }
}
 
开发者ID:mthli,项目名称:Knife,代码行数:23,代码来源:KnifeTagHandler.java

示例5: buildDialogText

import android.text.style.BulletSpan; //导入依赖的package包/类
private CharSequence buildDialogText(@NonNull Context context, @StringRes int intro,
        @StringRes int bullet1, @StringRes int bullet2, @StringRes int bullet3,
        @ColorInt int color) {
    SpannableStringBuilder ssb = new SpannableStringBuilder(context.getString(intro));
    int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_normal);
    ssb.append("\n\n");
    ssb.append(context.getString(bullet1),
            new BulletSpan(padding, color), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    ssb.append("\n\n");
    ssb.append(context.getString(bullet2),
            new BulletSpan(padding, color), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    ssb.append("\n\n");
    ssb.append(context.getString(bullet3),
            new BulletSpan(padding, color), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}
 
开发者ID:google,项目名称:iosched,代码行数:17,代码来源:MyIODialogFragment.java

示例6: handleTag

import android.text.style.BulletSpan; //导入依赖的package包/类
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
	switch (tag) {
		case "pre":
		case "PRE":
			ensureParagraphBoundary(output);
			break;
		// Unfortunately the following code will be ignored in API 24+ and the native rendering is inferior
		case "li":
		case "LI":
			if (opening) {
				liStarts.addLast(ensureParagraphBoundary(output));
			} else if (!liStarts.isEmpty()) {
				int start = liStarts.popLast();
				trimStart(output, start);
				int end = ensureParagraphBoundary(output);
				// Add leading margin to ensure the bullet is not cut off
				output.setSpan(new LeadingMarginSpan.Standard(leadingMargin), start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
				output.setSpan(new BulletSpan(bulletGapWidth), start, end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
			}
			break;
	}
}
 
开发者ID:cbeyls,项目名称:fosdem-companion-android,代码行数:24,代码来源:StringUtils.java

示例7: init

import android.text.style.BulletSpan; //导入依赖的package包/类
@SuppressWarnings("checkstyle:magicnumber") private void init(@NonNull String qNumber) {
    inflate(getContext(), R.layout.view_description_edit_revert_help, this);
    ButterKnife.bind(this);
    helpText.setMovementMethod(new LinkMovementMethod());

    Spanned helpStr = StringUtil.fromHtml(getString(R.string.description_edit_revert_help_body)
            .replaceAll(":revertSubtitle", getString(R.string.description_edit_revert_subtitle))
            .replaceAll(":revertIntro", getString(R.string.description_edit_revert_intro))
            .replaceAll(":revertHistory",
                    String.format(getString(R.string.description_edit_revert_history), getHistoryUri(qNumber))));

    int gapWidth = DimenUtil.roundedDpToPx(8);
    SpannableString revertReason1 = new SpannableString(StringUtil.fromHtml(String.format(getString(R.string.description_edit_revert_reason1), getString(R.string.wikidata_description_guide_url))));
    SpannableString revertReason2 = new SpannableString(StringUtil.fromHtml(getString(R.string.description_edit_revert_reason2)));
    revertReason1.setSpan(new BulletSpan(gapWidth), 0, revertReason1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    revertReason2.setSpan(new BulletSpan(gapWidth), 0, revertReason2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SpannableString helpSpan = new SpannableString(TextUtils.expandTemplate(helpStr, revertReason1, revertReason2));
    helpText.setText(helpSpan);
}
 
开发者ID:wikimedia,项目名称:apps-android-wikipedia,代码行数:20,代码来源:DescriptionEditRevertHelpView.java

示例8: handleULTag

import android.text.style.BulletSpan; //导入依赖的package包/类
private void handleULTag(Editable output) {
    if(output.length() > 0 && output.charAt(output.length() - 1) != '\n') {
        output.append("\n");
    }

    if(mLists.peek().second) {
        //Check for checkboxes
        if(output.length() > 2 &&
                ((output.charAt(0) >= '\u2610' && output.charAt(0) <= '\u2612')
                        || (output.charAt(1) >= '\u2610' && output
                        .charAt(1) <= '\u2612')
                )) {
            end(output, Ul.class, false,
                    new LeadingMarginSpan.Standard(
                            mListIndent * (mLists.size() - 1))
            );
        } else {
            end(output, Ul.class, false,
                    new LeadingMarginSpan.Standard(
                            mListIndent * (mLists.size() - 1)),
                    new BulletSpan(mSingleIndent)
            );
        }
    } else {
        end(output, Ul.class, false,
                new LeadingMarginSpan.Standard(mListIndent * (mLists.size() - 1))
        );
    }
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:30,代码来源:HtmlTagHandler.java

示例9: insertBullet

import android.text.style.BulletSpan; //导入依赖的package包/类
public TextDecorator insertBullet(final int gapWidth, @ColorRes final int colorResId, final int start, final int end) {
  checkIndexOutOfBoundsException(start, end);
  decoratedContent.setSpan(new BulletSpan(gapWidth, ContextCompat.getColor(textView.getContext(), colorResId)), start, end,
      flags);

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

示例10: testListAsterisk

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

示例11: testListMinus

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

示例12: testListPlus

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

示例13: ul

import android.text.style.BulletSpan; //导入依赖的package包/类
@Override
public SpannableStringBuilder ul(CharSequence charSequence, int level) {
    SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(charSequence);
    BulletSpan bulletSpan = new MarkDownBulletSpan(level, h1_text_color, 0);
    spannableStringBuilder.setSpan(bulletSpan, 0, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableStringBuilder;
}
 
开发者ID:zzhoujay,项目名称:Markdown,代码行数:8,代码来源:StyleBuilderImpl.java

示例14: ol

import android.text.style.BulletSpan; //导入依赖的package包/类
@Override
public SpannableStringBuilder ol(CharSequence charSequence, int level, int index) {
    SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(charSequence);
    BulletSpan bulletSpan = new MarkDownBulletSpan(level, h1_text_color, index);
    spannableStringBuilder.setSpan(bulletSpan, 0, spannableStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return spannableStringBuilder;
}
 
开发者ID:zzhoujay,项目名称:Markdown,代码行数:8,代码来源:StyleBuilderImpl.java

示例15: parseBulletLists

import android.text.style.BulletSpan; //导入依赖的package包/类
/**
 * Parse any bulleted lists in the text and apply a bulleted list formatting to the list items
 */
private void parseBulletLists(){
	for (int start = indexOf(builder, BULLET_LIST), end = indexOf(builder, "\n", start); start != -1;
		 start = indexOf(builder, BULLET_LIST, end), end = indexOf(builder, "\n", start)){
		//If the last thing in the text is a list item then go to the end
		if (end == -1){
			end = builder.length() - 1;
		}
		builder.setSpan(new BulletSpan(BulletSpan.STANDARD_GAP_WIDTH), start + BULLET_LIST.length(), end,
			Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
		builder.delete(start, start + BULLET_LIST.length());
		//Account for the shorter length of the text with the tag removed
		end -= BULLET_LIST.length();
	}
}
 
开发者ID:stuxo,项目名称:PTHAndroid,代码行数:18,代码来源:WhatBBParser.java


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