fixed npe caused by null emoji support

This commit is contained in:
Mariotaku Lee 2015-12-29 17:01:49 +08:00
parent 5e31c1f643
commit e2c79d7438
2 changed files with 3 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}