Search in sources :

Example 1 with EmojiParser

use of org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser in project Signal-Android by WhisperSystems.

the class EmojiProvider method emojify.

@Nullable
Spannable emojify(@Nullable CharSequence text, @NonNull TextView tv) {
    if (text == null)
        return null;
    List<EmojiParser.Candidate> matches = new EmojiParser(emojiTree).findCandidates(text);
    SpannableStringBuilder builder = new SpannableStringBuilder(text);
    for (EmojiParser.Candidate candidate : matches) {
        Drawable drawable = getEmojiDrawable(candidate.getDrawInfo());
        if (drawable != null) {
            builder.setSpan(new EmojiSpan(drawable, tv), candidate.getStartIndex(), candidate.getEndIndex(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    return builder;
}
Also used : EmojiParser(org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser) Drawable(android.graphics.drawable.Drawable) SpannableStringBuilder(android.text.SpannableStringBuilder) Nullable(android.support.annotation.Nullable)

Aggregations

Drawable (android.graphics.drawable.Drawable)1 Nullable (android.support.annotation.Nullable)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1 EmojiParser (org.thoughtcrime.securesms.components.emoji.parsing.EmojiParser)1