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


Java ParcelableSpan类代码示例

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


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

示例1: createSpanForMatches

import android.text.ParcelableSpan; //导入依赖的package包/类
/**
 * Create Span for matches in ParcelableSpan's. Note that this will highlight the full matched pattern
 * (including optionals) if no group parameters are given.
 *
 * @param editable      Text editable
 * @param pattern       The pattern to match
 * @param creator       A ParcelableSpanCreator for ParcelableSpan
 * @param groupsToMatch (optional) groups to be matched, indexes start at 1.
 */
protected void createSpanForMatches(final Editable editable, final Pattern pattern, final ParcelableSpanCreator creator, int... groupsToMatch) {
    if (groupsToMatch == null || groupsToMatch.length < 1) {
        groupsToMatch = new int[]{0};
    }
    int i = 0;
    for (Matcher m = pattern.matcher(editable); m.find(); i++) {
        ParcelableSpan span = creator.create(m, i);
        if (span != null) {
            for (int g : groupsToMatch) {
                if (g == 0 || g <= m.groupCount()) {
                    editable.setSpan(span, m.start(g), m.end(g), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                }
            }
        }
    }
}
 
开发者ID:gsantner,项目名称:markor,代码行数:26,代码来源:Highlighter.java

示例2: createSpan

import android.text.ParcelableSpan; //导入依赖的package包/类
/**
 * Returns a {@link Spannable} which attaches the specified {@link ParcelableSpan} to the given
 * substring
 *
 * @param text Text
 * @param span array of {@link ParcelableSpan} that will be applied
 * @param spanTexts array of substrings that will be modified
 *
 * @return {@link Spannable}
 */
@NonNull public Spannable createSpan(String text, ParcelableSpan[] span, String... spanTexts) {

  Spannable result = new SpannableString(text);

  if (span != null && spanTexts != null && span.length <= spanTexts.length) {

    for (int i = 0; i < span.length; i++) {
      String spanText = spanTexts[i];
      int spanTextStart = text.indexOf(spanText);
      if (spanTextStart >= 0
          && spanTextStart < text.length()
          && spanText.length() <= text.length()) {
        result.setSpan(span[i], spanTextStart, (spanTextStart + spanText.length()),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
    }
  }
  return result;
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:30,代码来源:SpannableFactory.java

示例3: createMultiSpan

import android.text.ParcelableSpan; //导入依赖的package包/类
@NonNull
public Spannable createMultiSpan(String text, ParcelableSpan[] span, String... spanTexts) {
  Spannable result = new SpannableString(text);
  for (ParcelableSpan parcelableSpan : span) {
    for (String spanText : spanTexts) {
      int spanTextStart = text.indexOf(spanText);
      if (spanTextStart >= 0
          && spanTextStart < text.length()
          && spanText.length() <= text.length()) {
        result.setSpan(parcelableSpan, spanTextStart, (spanTextStart + spanText.length()),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      }
    }
  }

  return result;
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:18,代码来源:SpannableFactory.java

示例4: setPost

import android.text.ParcelableSpan; //导入依赖的package包/类
@Override public void setPost(TimelineUser card, int position) {
  followers.setText(spannableFactory.createSpan(itemView.getContext()
          .getString(R.string.timeline_button_followers, card.getFollowers()),
      new ParcelableSpan[] { new ForegroundColorSpan(Color.BLACK) },
      String.valueOf(card.getFollowers()), String.valueOf(card.getFollowers())));
  following.setText(spannableFactory.createSpan(itemView.getContext()
          .getString(R.string.timeline_button_followed, card.getFollowing()),
      new ParcelableSpan[] { new ForegroundColorSpan(Color.BLACK) },
      String.valueOf(card.getFollowing()), String.valueOf(card.getFollowing())));

  followers.setOnClickListener(click -> cardTouchEventPublishSubject.onNext(
      new TimelineStatsTouchEvent(card, TimelineStatsTouchEvent.ButtonClicked.FOLLOWERS,
          CardTouchEvent.Type.TIMELINE_STATS, position)));
  following.setOnClickListener(click -> cardTouchEventPublishSubject.onNext(
      new TimelineStatsTouchEvent(card, TimelineStatsTouchEvent.ButtonClicked.FOLLOWING,
          CardTouchEvent.Type.TIMELINE_STATS, position)));
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:18,代码来源:TimelineStatsViewHolder.java

示例5: create

import android.text.ParcelableSpan; //导入依赖的package包/类
public ParcelableSpan create(Matcher m, int iM) {
    final char[] charSequence = extractMatchingRange(m);
    Float proportion = calculateProportionBasedOnHeaderType(charSequence);
    Float size = calculateAdjustedSize(proportion);
    return new TextAppearanceSpan(_highlighter._fontType, Typeface.BOLD, (int) size.byteValue(),
            ColorStateList.valueOf(_color), null);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:8,代码来源:MarkdownHeaderSpanCreator.java

示例6: getFollowersText

import android.text.ParcelableSpan; //导入依赖的package包/类
CharSequence getFollowersText(Context context) {

    return spannableFactory.createSpan(context.getString(R.string.timeline_button_followers,
        getPojo().getData()
            .getFollowers()), new ParcelableSpan[] { new ForegroundColorSpan(Color.BLACK) },
        String.valueOf(getPojo().getData()
            .getFollowers()), String.valueOf(getPojo().getData()
            .getFollowers()));
  }
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:10,代码来源:TimeLineStatsDisplayable.java

示例7: getFollowingText

import android.text.ParcelableSpan; //导入依赖的package包/类
CharSequence getFollowingText(Context context) {

    return spannableFactory.createSpan(context.getString(R.string.timeline_button_followed,
        getPojo().getData()
            .getFollowing()), new ParcelableSpan[] { new ForegroundColorSpan(Color.BLACK) },
        String.valueOf(getPojo().getData()
            .getFollowing()), String.valueOf(getPojo().getData()
            .getFollowing()));
  }
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:10,代码来源:TimeLineStatsDisplayable.java

示例8: createSpan

import android.text.ParcelableSpan; //导入依赖的package包/类
private Spannable createSpan(String text, ParcelableSpan span, String[] spanTexts) {
  final Spannable result = new SpannableString(text);
  for (String spanText : spanTexts) {
    int spanTextStart = text.indexOf(spanText);
    if (spanTextStart >= 0
        && spanTextStart < text.length()
        && spanText.length() <= text.length()) {
      result.setSpan(span, spanTextStart, (spanTextStart + spanText.length()),
          Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
  }
  return result;
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:14,代码来源:ShareAptoideActivity.java

示例9: showAppsCount

import android.text.ParcelableSpan; //导入依赖的package包/类
private void showAppsCount(long appsCount, ParcelableSpan[] textStyle, boolean showApps,
    long storeName) {
  if (showApps) {
    appsCountTv.setVisibility(View.VISIBLE);
    String count = AptoideUtils.StringU.withSuffix(appsCount);
    String followingText =
        String.format(getContext().getString(R.string.storehometab_short_apps), count);
    appsCountTv.setText(spannableFactory.createMultiSpan(followingText, textStyle, count));
    appsCountTv.setOnClickListener(v -> navigateToAppsListScreen(storeName));
  } else {
    appsCountTv.setVisibility(View.GONE);
  }
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:14,代码来源:GridStoreMetaWidget.java

示例10: removeParcelableSpans

import android.text.ParcelableSpan; //导入依赖的package包/类
/**
 * This is used to remove all style-impacting spans from text before new
 * extracted text is being replaced into it, so that we don't have any
 * lingering spans applied during the replace.
 */
static void removeParcelableSpans(Spannable spannable, int start, int end) {
    Object[] spans = spannable.getSpans(start, end, ParcelableSpan.class);
    int i = spans.length;
    while (i > 0) {
        i--;
        spannable.removeSpan(spans[i]);
    }
}
 
开发者ID:AungThiha,项目名称:Tada,代码行数:14,代码来源:TextView.java

示例11: clear

import android.text.ParcelableSpan; //导入依赖的package包/类
public static void clear(final Editable editable) {
    final int end = editable.length() - 1;
    for (Class<? extends ParcelableSpan> clazz : SPAN_CLASSES) {
        for (ParcelableSpan span : editable.getSpans(0, end, clazz)) {
            editable.removeSpan(span);
        }
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:9,代码来源:StylingHelper.java

示例12: createSpanForStyle

import android.text.ParcelableSpan; //导入依赖的package包/类
private static ParcelableSpan createSpanForStyle(ImStyleParser.Style style) {
    switch (style.getKeyword()) {
        case "*":
            return new StyleSpan(Typeface.BOLD);
        case "_":
            return new StyleSpan(Typeface.ITALIC);
        case "~":
            return new StrikethroughSpan();
        case "`":
        case "```":
            return new TypefaceSpan("monospace");
        default:
            throw new AssertionError("Unknown Style");
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:16,代码来源:StylingHelper.java

示例13: clear

import android.text.ParcelableSpan; //导入依赖的package包/类
public static void clear(final Editable editable) {
	final int end = editable.length() - 1;
	for (Class<? extends ParcelableSpan> clazz : SPAN_CLASSES) {
		for (ParcelableSpan span : editable.getSpans(0, end, clazz)) {
			editable.removeSpan(span);
		}
	}
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:9,代码来源:StylingHelper.java

示例14: createSpanForStyle

import android.text.ParcelableSpan; //导入依赖的package包/类
private static ParcelableSpan createSpanForStyle(ImStyleParser.Style style) {
	switch (style.getKeyword()) {
		case "*":
			return new StyleSpan(Typeface.BOLD);
		case "_":
			return new StyleSpan(Typeface.ITALIC);
		case "~":
			return new StrikethroughSpan();
		case "`":
		case "```":
			return new TypefaceSpan("monospace");
		default:
			throw new AssertionError("Unknown Style");
	}
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:16,代码来源:StylingHelper.java

示例15: create

import android.text.ParcelableSpan; //导入依赖的package包/类
public ParcelableSpan create(Matcher m) {
    final char[] charSequence = extractMatchingRange(m);
    Float proportion = calculateProportionBasedOnHeaderType(charSequence);
    Float size = calculateAdjustedSize(proportion);
    return new TextAppearanceSpan(highlighter.fontType, Typeface.BOLD, (int) size.byteValue(),
            ColorStateList.valueOf(color), null);
}
 
开发者ID:plafue,项目名称:writeily-pro,代码行数:8,代码来源:HeaderSpanCreator.java


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