use of android.text.SpannableStringBuilder in project actor-platform by actorapp.
the class ActorBinder method bind.
public void bind(final TextView textView, final View titleContainer, final GroupVM value) {
bind(value.getPresence(), value.getMembersCount(), value.isMember(), (online, onlineModel, membersCount, membersModel, isMember, isMemberModel) -> {
if (isMember) {
titleContainer.setVisibility(View.VISIBLE);
if (online <= 0) {
SpannableStringBuilder builder = new SpannableStringBuilder(messenger().getFormatter().formatGroupMembers(membersCount));
builder.setSpan(new ForegroundColorSpan(0xB7ffffff), 0, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(builder);
} else {
SpannableStringBuilder builder = new SpannableStringBuilder(messenger().getFormatter().formatGroupMembers(membersCount) + ", ");
builder.setSpan(new ForegroundColorSpan(0xB7ffffff), 0, builder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
builder.append(messenger().getFormatter().formatGroupOnline(online));
textView.setText(builder);
}
} else {
titleContainer.setVisibility(View.GONE);
}
});
}
use of android.text.SpannableStringBuilder in project actor-platform by actorapp.
the class MessageHolder method setTimeAndReactions.
protected void setTimeAndReactions(TextView time) {
Spannable timeWithReactions = null;
if (reactions != null) {
SpannableStringBuilder builder = new SpannableStringBuilder(reactions);
timeWithReactions = builder.append(DateFormatting.formatTime(currentMessage.getDate()));
}
time.setText(timeWithReactions != null ? timeWithReactions : DateFormatting.formatTime(currentMessage.getDate()));
time.setMovementMethod(LinkMovementMethod.getInstance());
}
use of android.text.SpannableStringBuilder in project actor-platform by actorapp.
the class AndroidNotifications method getNotificationTextFull.
private CharSequence getNotificationTextFull(Notification notification, Messenger messenger) {
SpannableStringBuilder res = new SpannableStringBuilder();
if (!messenger.getFormatter().isLargeDialogMessage(notification.getContentDescription().getContentType())) {
res.append(getNotificationSender(notification));
res.append(": ");
res.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, res.length(), 0);
}
res.append(messenger.getFormatter().formatNotificationText(notification));
return res;
}
use of android.text.SpannableStringBuilder in project actor-platform by actorapp.
the class AndroidMarkdown method processText.
private static Spannable processText(String markdown, int mode) {
MDDocument doc = new MarkdownParser(mode).processDocument(markdown);
SpannableStringBuilder builder = new SpannableStringBuilder();
boolean isFirst = true;
for (MDSection s : doc.getSections()) {
if (isFirst) {
isFirst = false;
} else {
builder.append("\n");
}
if (s.getType() == MDSection.TYPE_CODE) {
int start = builder.length();
builder.append("View Source Code");
final String text = s.getCode().getCode();
builder.setSpan(new RelativeSizeSpan(1.1f), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan(Color.RED), start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
AndroidContext.getContext().startActivity(new Intent(AndroidContext.getContext(), CodePreviewActivity.class).putExtra("source_code", text).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}, start, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (s.getType() == MDSection.TYPE_TEXT) {
writeText(s.getText(), builder);
} else {
throw new RuntimeException("Unknown section type: " + s.getType());
}
}
return builder;
}
use of android.text.SpannableStringBuilder in project actor-platform by actorapp.
the class SearchViewHacker method setHint.
public static void setHint(SearchView searchView, String hint, int resId, int color, Resources resources) {
AutoCompleteTextView autoComplete = (AutoCompleteTextView) findView(searchView, "mQueryTextView");
SpannableStringBuilder stopHint = new SpannableStringBuilder("");
stopHint.append(hint);
autoComplete.setHint(stopHint);
autoComplete.setHintTextColor(color);
}
Aggregations