From a66069abd83900b5f6b5333756d67e93b6edb3c1 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 20 Nov 2014 15:07:21 +0900 Subject: [PATCH] Fix possible NPE in MainKeyboardView Change-Id: I1fc21a981d9f1740315763b5ca0c1024ece1fa4d --- .../com/android/inputmethod/keyboard/MainKeyboardView.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 06b87bd9a..a1dd7ec20 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -895,13 +895,16 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy } private void drawLanguageOnSpacebar(final Key key, final Canvas canvas, final Paint paint) { + final Keyboard keyboard = getKeyboard(); + if (keyboard == null) { + return; + } final int width = key.getWidth(); final int height = key.getHeight(); paint.setTextAlign(Align.CENTER); paint.setTypeface(Typeface.DEFAULT); paint.setTextSize(mLanguageOnSpacebarTextSize); - final RichInputMethodSubtype subtype = getKeyboard().mId.mSubtype; - final String language = layoutLanguageOnSpacebar(paint, subtype, width); + final String language = layoutLanguageOnSpacebar(paint, keyboard.mId.mSubtype, width); // Draw language text with shadow final float descent = paint.descent(); final float textHeight = -paint.ascent() + descent;