Search in sources :

Example 51 with Spannable

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());
}
Also used : Spannable(android.text.Spannable) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 52 with Spannable

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);
}
Also used : PreprocessedTextData(im.actor.sdk.controllers.conversation.messages.content.preprocessor.PreprocessedTextData) Spannable(android.text.Spannable)

Example 53 with Spannable

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();
}
Also used : SpannableString(android.text.SpannableString) UserSpan(im.actor.sdk.controllers.compose.view.UserSpan) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Example 54 with Spannable

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);
}
Also used : Spannable(android.text.Spannable) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 55 with Spannable

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;
}
Also used : SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Aggregations

Spannable (android.text.Spannable)333 Paint (android.graphics.Paint)122 TextPaint (android.text.TextPaint)97 SpannableString (android.text.SpannableString)72 Editable (android.text.Editable)42 InputMethodManager (android.view.inputmethod.InputMethodManager)34 Spanned (android.text.Spanned)32 SuggestionSpan (android.text.style.SuggestionSpan)29 View (android.view.View)28 SpannableStringBuilder (android.text.SpannableStringBuilder)24 ForegroundColorSpan (android.text.style.ForegroundColorSpan)21 TextView (android.widget.TextView)17 ClickableSpan (android.text.style.ClickableSpan)14 StyleSpan (android.text.style.StyleSpan)14 Intent (android.content.Intent)13 KeyEvent (android.view.KeyEvent)13 URLSpan (android.text.style.URLSpan)12 Layout (android.text.Layout)11 Parcelable (android.os.Parcelable)8 SpannedString (android.text.SpannedString)8