use of android.text.Spannable 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.Spannable in project actor-platform by actorapp.
the class TextHolder method bindData.
@Override
protected void bindData(final Message message, long readDate, long receiveDate, boolean isUpdated, PreprocessedData preprocessedData) {
PreprocessedTextData textData = (PreprocessedTextData) preprocessedData;
Spannable reactions = preprocessedData.getReactionsSpannable();
CharSequence text;
if (textData.getSpannableString() != null) {
text = textData.getSpannableString();
} else {
text = textData.getText();
}
bindRawText(text, readDate, receiveDate, reactions, message, false);
}
use of android.text.Spannable in project actor-platform by actorapp.
the class GroupUsersFragment method updateEditText.
private void updateEditText() {
Integer[] selected = getSelected();
String src = "";
for (int i = 0; i < selected.length; i++) {
src += "!";
}
Spannable spannable = new SpannableString(src);
for (int i = 0; i < selected.length; i++) {
spannable.setSpan(new UserSpan(users().get(selected[i]), Screen.dp(200)), i, i + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
searchField.removeTextChangedListener(textWatcher);
searchField.setText(spannable);
searchField.setSelection(spannable.length());
searchField.addTextChangedListener(textWatcher);
filter("");
getAdapter().notifyDataSetChanged();
}
use of android.text.Spannable in project android_frameworks_base by ParanoidAndroid.
the class SpannableTest method testGetSpans.
@MediumTest
public void testGetSpans() {
Spannable spannable = newSpannableWithText("abcdef");
Object emptySpan = new Object();
spannable.setSpan(emptySpan, 1, 1, 0);
Object unemptySpan = new Object();
spannable.setSpan(unemptySpan, 1, 2, 0);
Object[] spans;
// Empty spans are included when they merely abut the query region
// but other spans are not, unless the query region is empty, in
// in which case any abutting spans are returned.
spans = spannable.getSpans(0, 1, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan }, spans);
spans = spannable.getSpans(0, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
spans = spannable.getSpans(1, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { emptySpan, unemptySpan }, spans);
spans = spannable.getSpans(2, 2, Object.class);
MoreAsserts.assertEquals(new Object[] { unemptySpan }, spans);
}
use of android.text.Spannable in project KeepScore by nolanlawson.
the class PlayerView method fromHistory.
/**
* Add green color for positive entries and red color for negative entries,
* and convert ints to strings.
*
* @param currentTime
*/
private Spannable fromHistory(List<Delta> history, long currentTime) {
history = historyToShow(history, currentTime);
if (history.isEmpty()) {
return null;
}
history = CollectionUtil.reversedCopy(history);
// if e.g. there is a double-digit delta (e.g. "+10"), then all other
// strings need to be padded
// so that they line up correctly
// but ensure there's always at least enough space for 3 chars (e.g.
// '+10'), because
// I think it looks nicer and more consistent with most games
int maxChars = Math.max(MIN_NUM_HISTORY_CHARS, CollectionUtil.maxValue(history, DELTA_TO_LENGTH_WITH_SIGN));
List<Spannable> spannables = CollectionUtil.transform(history, historyToSpan(maxChars));
Spannable result = new SpannableString(StringUtil.joinSpannables("\n", CollectionUtil.toArray(spannables, Spannable.class)));
return result;
}
Aggregations