Java Code Examples for android.text.SpannableString#toString()

The following examples show how to use android.text.SpannableString#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostItem.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
public CharSequence getComment(String repliesToPost) {
	SpannableString comment = new SpannableString(getComment());
	LinkSpan[] spans = comment.getSpans(0, comment.length(), LinkSpan.class);
	if (spans != null) {
		String commentString = comment.toString();
		repliesToPost = ">>" + repliesToPost;
		for (LinkSpan linkSpan : spans) {
			int start = comment.getSpanStart(linkSpan);
			if (commentString.indexOf(repliesToPost, start) == start) {
				int end = comment.getSpanEnd(linkSpan);
				comment.setSpan(new StyleSpan(Typeface.BOLD), start, end, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
			}
		}
	}
	return comment;
}
 
Example 2
Source File: PostActivity.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 6 votes vote down vote up
private PostParam getPostParam() {
    Intent intent = getIntent();
    String tid = intent.getStringExtra(ParamKey.KEY_TID);
    int fid = intent.getIntExtra(ParamKey.KEY_FID, -7);
    String title = intent.getStringExtra("title");
    String pid = intent.getStringExtra(ParamKey.KEY_PID);
    String action = intent.getStringExtra(ParamKey.KEY_ACTION);
    String prefix = intent.getStringExtra("prefix");
    if (prefix != null && prefix.startsWith("[quote][pid=") && prefix.endsWith("[/quote]\n")) {
        SpannableString spanString = new SpannableString(prefix);
        spanString.setSpan(new BackgroundColorSpan(-1513240), 0, prefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spanString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), prefix.indexOf("[b]Post by"), prefix.indexOf("):[/b]") + 5, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        prefix = spanString.toString();
    }
    PostParam act = new PostParam(tid, "", "");
    act.setPostAction(action);
    act.setPostFid(fid);
    act.setPostPid(pid);
    act.setPostContent(prefix);
    act.setPostSubject(title);
    return act;
}
 
Example 3
Source File: Util.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
public static void setGray(SpannableString ss, List<String> items) {
    String data = ss.toString();

    for (String item : items) {
        int i = data.indexOf("@" + item);

        if (i != -1) {
            ss.setSpan(new ForegroundColorSpan(Color.GRAY), i,
                    i + 1 + item.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        int j = data.indexOf("+" + item);

        if (j != -1) {
            ss.setSpan(new ForegroundColorSpan(Color.GRAY), j,
                    j + 1 + item.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
 
Example 4
Source File: StringUtils.java    From letv with Apache License 2.0 5 votes vote down vote up
public static SpannableString highlightParamTextBetweenTwoString(SpannableString spanString, String beforeHighlight, String afterHighlight, int color) {
    String inputString = spanString.toString();
    if (!TextUtils.isEmpty(inputString)) {
        int beginPos = inputString.indexOf(beforeHighlight) + beforeHighlight.length();
        if (beginPos > -1) {
            int endPos = inputString.indexOf(afterHighlight);
            if (endPos > -1 && beginPos < endPos) {
                spanString.setSpan(new ForegroundColorSpan(color), beginPos, endPos, 33);
            }
        }
    }
    return spanString;
}
 
Example 5
Source File: StyleSmallDecimal.java    From px-android with MIT License 5 votes vote down vote up
@Override
public Spannable apply(final int holder, final Context context) {
    final Spannable spanned = apply(null);
    final Currency currency = amountFormatter.currencyFormatter.currency;
    final Character decimalSeparator = currency.getDecimalSeparator();
    final SpannableString spannableString = new SpannableString(TextUtil.format(context, holder, spanned));
    final String totalText = spannableString.toString();
    return makeSmallAfterSeparator(decimalSeparator, totalText);
}
 
Example 6
Source File: NanoStatus.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static String nanoStatus(final String module) {
    final SpannableString result = nanoStatusColor(module);
    return result != null ? result.toString() : null;
}
 
Example 7
Source File: NanoStatus.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static String nanoStatus(final String module) {
    final SpannableString result = nanoStatusColor(module);
    return result != null ? result.toString() : null;
}
 
Example 8
Source File: NanoStatus.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static String nanoStatus(final String module) {
    final SpannableString result = nanoStatusColor(module);
    return result != null ? result.toString() : null;
}
 
Example 9
Source File: NanoStatus.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static String nanoStatus(final String module) {
    final SpannableString result = nanoStatusColor(module);
    return result != null ? result.toString() : null;
}