From 035f0f5c94136fa1c209d5d209ab8f27d4ca016e Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Fri, 22 Jul 2011 06:14:22 +0900
Subject: [PATCH] Fix NPE

bug: 5054162
Change-Id: I69d308f0eeb32968515100dde98ad51a7c35020e
---
 java/src/com/android/inputmethod/keyboard/KeyboardView.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index d23b8ff0eb..1641dc4a5d 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -136,6 +136,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
         @Override
         public void handleMessage(Message msg) {
             final KeyboardView keyboardView = getOuterInstance();
+            if (keyboardView == null) return;
             final PointerTracker tracker = (PointerTracker) msg.obj;
             switch (msg.what) {
             case MSG_SHOW_KEY_PREVIEW:
@@ -150,8 +151,9 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
         }
 
         public void showKeyPreview(long delay, int keyIndex, PointerTracker tracker) {
-            final KeyboardView keyboardView = getOuterInstance();
             removeMessages(MSG_SHOW_KEY_PREVIEW);
+            final KeyboardView keyboardView = getOuterInstance();
+            if (keyboardView == null) return;
             if (keyboardView.mPreviewText.getVisibility() == VISIBLE || delay == 0) {
                 // Show right away, if it's already visible and finger is moving around
                 keyboardView.showKey(keyIndex, tracker);
-- 
GitLab