use of android.text.SpannableString in project wh-app-android by WhiteHouse.
the class FeedItemListFragment method onStart.
@Override
public void onStart() {
super.onStart();
showList(false);
showProgress(true);
if (mFeedType == TYPE_FAVORITES) {
bindSubscription(AndroidObservable.bindFragment(this, FeedManager.observeFavorites()).map(feedItems -> {
List<FeedItemData> processed = new ArrayList<>(feedItems.size());
FeedItemData data;
for (FeedItem item : feedItems) {
data = new FeedItemData();
data.item = item;
processed.add(data);
}
return processed;
}).subscribe(this));
FeedManager.updateFavorites(getActivity());
} else {
bindSubscription(fetchData());
String viewType;
switch(mFeedType) {
default:
case TYPE_ARTICLE:
viewType = FeedCategoryItem.VIEW_TYPE_ARTICLE_LIST;
break;
case TYPE_LIVE:
viewType = FeedCategoryItem.VIEW_TYPE_LIVE;
break;
case TYPE_PHOTOS:
viewType = FeedCategoryItem.VIEW_TYPE_PHOTO_GALLERY;
break;
case TYPE_VIDEOS:
viewType = FeedCategoryItem.VIEW_TYPE_VIDEO_GALLERY;
break;
}
FeedManager.updateFeedFromServer(mFeedUrl, mFeedTitle, viewType);
}
if (mFeedType == TYPE_FAVORITES) {
Drawable d = getResources().getDrawable(R.drawable.ic_action_bookmark_outline);
String s = getString(R.string.empty_favorites_list);
SpannableString ss = new SpannableString(s);
ImageSpan is = new ImageSpan(d, ImageSpan.ALIGN_BOTTOM);
int index = s.indexOf("{icon}");
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
d.setColorFilter(Color.DKGRAY, PorterDuff.Mode.MULTIPLY);
ss.setSpan(is, index, index + 6, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
getEmptyView().setText(ss);
} else if (mFeedType == TYPE_LIVE) {
getEmptyView().setText(R.string.empty_live_list);
}
if (getTracker() != null) {
getTracker().setScreenName("FeedItemList");
if (mFeedType == TYPE_FAVORITES) {
getTracker().setPage("Favorites");
} else {
getTracker().setPage(mFeedUrl);
}
}
}
use of android.text.SpannableString in project android_frameworks_base by ResurrectionRemix.
the class ValidateNotificationPeopleTest method testSingleCharSequence.
@SmallTest
public void testSingleCharSequence() throws Exception {
String[] expected = { "foobar" };
Bundle bundle = new Bundle();
bundle.putCharSequence(Notification.EXTRA_PEOPLE, new SpannableString(expected[0]));
String[] result = ValidateNotificationPeople.getExtraPeople(bundle);
assertStringArrayEquals("charSequence should be in result[0]", expected, result);
}
use of android.text.SpannableString in project Rocket.Chat.Android by RocketChat.
the class Linkify method markupInner.
private static SpannableString markupInner(final CharSequence text) {
LinkExtractor linkExtractor = LinkExtractor.builder().linkTypes(sTargetType).build();
SpannableString spannableString = new SpannableString(text);
for (LinkSpan link : linkExtractor.extractLinks(text)) {
final int idx1 = link.getBeginIndex();
final int idx2 = link.getEndIndex();
final String url = text.subSequence(idx1, idx2).toString();
spannableString.setSpan(MarkDown.createLinkSpan(url), idx1, idx2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return spannableString;
}
use of android.text.SpannableString in project Rocket.Chat.Android by RocketChat.
the class MarkDown method apply.
/**
* transform MarkDown text into Spans.
*/
public static void apply(TextView textView) {
SpannableString text = new SpannableString(textView.getText());
removeImage(text);
highlightLink1(text);
highlightLink2(text);
bold(text);
italic(text);
strike(text);
textView.setText(text);
}
use of android.text.SpannableString in project android_frameworks_base by ResurrectionRemix.
the class TextView method removeSuggestionSpans.
/**
* Removes the suggestion spans.
*/
CharSequence removeSuggestionSpans(CharSequence text) {
if (text instanceof Spanned) {
Spannable spannable;
if (text instanceof Spannable) {
spannable = (Spannable) text;
} else {
spannable = new SpannableString(text);
text = spannable;
}
SuggestionSpan[] spans = spannable.getSpans(0, text.length(), SuggestionSpan.class);
for (int i = 0; i < spans.length; i++) {
spannable.removeSpan(spans[i]);
}
}
return text;
}
Aggregations