From e2c79d74386e664e48bcf9ab6d20750e77133981 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Tue, 29 Dec 2015 17:01:49 +0800 Subject: [PATCH] fixed npe caused by null emoji support --- .../java/org/mariotaku/twidere/util/EmojiSupportUtils.java | 2 +- .../java/org/mariotaku/twidere/util/ExternalThemeManager.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/EmojiSupportUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/EmojiSupportUtils.java index 4a368b139..bfe3bc8e6 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/EmojiSupportUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/EmojiSupportUtils.java @@ -47,7 +47,7 @@ public class EmojiSupportUtils { public static void applyEmoji(ExternalThemeManager manager, @NonNull Spannable text, int textStart, int textLength) { final ExternalThemeManager.Emoji emoji = manager.getEmoji(); - if (!emoji.isSupported()) return; + if (emoji == null || !emoji.isSupported()) return; final CodePointArray array = new CodePointArray(text); for (int arrayIdx = array.length() - 1; arrayIdx >= 0; arrayIdx--) { final int codePoint = array.get(arrayIdx); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ExternalThemeManager.java b/twidere/src/main/java/org/mariotaku/twidere/util/ExternalThemeManager.java index 44d4cead0..f0599d222 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ExternalThemeManager.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ExternalThemeManager.java @@ -26,6 +26,7 @@ import android.content.pm.PackageManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.content.res.ResourcesCompat; import android.util.LruCache; @@ -72,7 +73,7 @@ public class ExternalThemeManager implements Constants { emoji = new Emoji(application, emojiPackageName); } - @NonNull + @Nullable public Emoji getEmoji() { return emoji; }