Fix crash on duplicate custom emojis
Fixes #274 Add a merge function to `Collectors.toMap` to discard any duplicate custom emojis that may be returned if a user uses the same custom emoji in both their name and profile.
This commit is contained in:
parent
0ee494bcfc
commit
244f2ed911
|
@ -129,7 +129,16 @@ public class HtmlParser{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void parseCustomEmoji(SpannableStringBuilder ssb, List<Emoji> emojis){
|
public static void parseCustomEmoji(SpannableStringBuilder ssb, List<Emoji> emojis){
|
||||||
Map<String, Emoji> emojiByCode=emojis.stream().collect(Collectors.toMap(e->e.shortcode, Function.identity()));
|
Map<String, Emoji> emojiByCode =
|
||||||
|
emojis.stream()
|
||||||
|
.collect(
|
||||||
|
Collectors.toMap(e->e.shortcode, Function.identity(), (emoji1, emoji2) -> {
|
||||||
|
// Ignore duplicate shortcodes and just take the first, it will be
|
||||||
|
// the same emoji anyway
|
||||||
|
return emoji1;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
Matcher matcher=EMOJI_CODE_PATTERN.matcher(ssb);
|
Matcher matcher=EMOJI_CODE_PATTERN.matcher(ssb);
|
||||||
int spanCount=0;
|
int spanCount=0;
|
||||||
CustomEmojiSpan lastSpan=null;
|
CustomEmojiSpan lastSpan=null;
|
||||||
|
|
Loading…
Reference in New Issue