當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。