List of usage examples for android.text Spanned SPAN_EXCLUSIVE_INCLUSIVE
int SPAN_EXCLUSIVE_INCLUSIVE
To view the source code for android.text Spanned SPAN_EXCLUSIVE_INCLUSIVE.
Click Source Link
From source file:com.googlecode.eyesfree.brailleback.DisplaySpans.java
/** * Marks a portion of {@code spannable} as containing text selection. If * {@code start} and {@code end} are equal, then then added span marks a * cursor.//w ww . ja v a 2s.co m */ public static void addSelection(Spannable spannable, int start, int end) { int flags; if (start == end) { flags = Spanned.SPAN_EXCLUSIVE_INCLUSIVE; } else { flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE; } spannable.setSpan(new SelectionSpan(), start, end, flags); }
From source file:fyp.hkust.facet.activity.SettingsActivity.java
private void convertPreferenceToUseCustomFont(Preference somePreference) { Typeface fontType = FontManager.getTypeface(getApplicationContext(), FontManager.APP_FONT); CustomTypeFaceSpan customTypefaceSpan = new CustomTypeFaceSpan("", fontType); SpannableStringBuilder ss;/*from w w w. j av a 2 s . c o m*/ if (somePreference.getTitle() != null) { ss = new SpannableStringBuilder(somePreference.getTitle().toString()); ss.setSpan(new StyleSpan(Typeface.BOLD), 0, ss.length(), 0); ss.setSpan(customTypefaceSpan, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); somePreference.setTitle(ss); } if (somePreference.getSummary() != null) { ss = new SpannableStringBuilder(somePreference.getSummary().toString()); ss.setSpan(customTypefaceSpan, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); somePreference.setSummary(ss); } }
From source file:com.tct.mail.utils.NotificationUtils.java
private static CharSequence getSingleMessageBigText(Context context, final Message message, String from) { final TextAppearanceSpan notificationSubjectSpan = new TextAppearanceSpan(context, R.style.NotificationPrimaryText); final String snippet = getMessageBodyWithoutElidedText(message); // Change multiple newlines (with potential white space between), into a single new line final String collapsedSnippet = !TextUtils.isEmpty(snippet) ? snippet.replaceAll("\\n\\s+", "\n") : ""; if (TextUtils.isEmpty(from)) { // If the subject is empty, just use the snippet. return snippet; } else if (TextUtils.isEmpty(collapsedSnippet)) { // If the snippet is empty, just use the subject. final SpannableString spannableString = new SpannableString(from); spannableString.setSpan(notificationSubjectSpan, 0, from.length(), 0); return spannableString; } else {//from ww w . j av a2s . co m final String notificationBigTextFormat = context.getResources() .getString(R.string.single_new_message_notification_big_text); // Localizers may change the order of the parameters, look at how the format // string is structured. final boolean isSubjectFirst = notificationBigTextFormat.indexOf("%2$s") > notificationBigTextFormat .indexOf("%1$s"); final String bigText = String.format(notificationBigTextFormat, from, collapsedSnippet); final SpannableString spannableString = new SpannableString(bigText); final int subjectOffset = (isSubjectFirst ? bigText.indexOf(from) : bigText.lastIndexOf(from)); spannableString.setSpan(new ForegroundColorSpan(Color.BLACK), subjectOffset, subjectOffset + from.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); return spannableString; } }