Prevent crash in emoji compat library when used right after the app started (cold start for a chat room shorcut for example)

This commit is contained in:
Sylvain Berfini 2023-04-07 09:45:32 +02:00
parent 8cd42efa8e
commit c2a649c50e

View file

@ -110,12 +110,20 @@ class AppUtils {
val emoji = emojiCompat
emoji ?: return false
for (split in text.split(" ")) {
// We only check the first and last chars of the split for commodity
if (emoji.getEmojiStart(split, 0) == -1 || emoji.getEmojiEnd(split, split.length - 1) == -1) {
return false
try {
for (split in text.split(" ")) {
// We only check the first and last chars of the split for commodity
if (emoji.getEmojiStart(split, 0) == -1
|| emoji.getEmojiEnd(split,split.length - 1) == -1)
{
return false
}
}
} catch (npe: NullPointerException) {
// This can happen in EmojiCompat library, mProcessor can be null (https://issuetracker.google.com/issues/277182750)
return false
}
return true
}