aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-08-21 10:42:49 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-08-21 16:56:45 +0900
commit8d0cf41f49b1962ecc255de13fe35d7f0a8c2f3d (patch)
tree99c3395c89d98489bdf577519be97095dcba634d /java/src
parent48643b0e0d73703f4b3357add9f793d521eedf96 (diff)
downloadlatinime-8d0cf41f49b1962ecc255de13fe35d7f0a8c2f3d.tar.gz
latinime-8d0cf41f49b1962ecc255de13fe35d7f0a8c2f3d.tar.xz
latinime-8d0cf41f49b1962ecc255de13fe35d7f0a8c2f3d.zip
Fix NPE
Bug: 7017430 Change-Id: Ie46f02a934763c3b6d65d0d62a8239d80eaefabd
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index ccbb081b4..fe14c3ffc 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -30,6 +30,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Message;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
@@ -78,6 +79,8 @@ import java.util.HashSet;
* @attr ref R.styleable#KeyboardView_shadowRadius
*/
public class KeyboardView extends View implements PointerTracker.DrawingProxy {
+ private static final String TAG = KeyboardView.class.getSimpleName();
+
// Miscellaneous constants
private static final int[] LONG_PRESSABLE_STATE_SET = { android.R.attr.state_long_pressable };
@@ -932,9 +935,18 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
final int[] viewOrigin = new int[2];
getLocationInWindow(viewOrigin);
mPreviewPlacerView.setOrigin(viewOrigin[0], viewOrigin[1]);
- final ViewGroup windowContentView =
- (ViewGroup)getRootView().findViewById(android.R.id.content);
- windowContentView.addView(mPreviewPlacerView);
+ final View rootView = getRootView();
+ if (rootView == null) {
+ Log.w(TAG, "Cannot find root view");
+ return;
+ }
+ final ViewGroup windowContentView = (ViewGroup)rootView.findViewById(android.R.id.content);
+ // Note: It'd be very weird if we get null by android.R.id.content.
+ if (windowContentView == null) {
+ Log.w(TAG, "Cannot find android.R.id.content view to add PreviewPlacerView");
+ } else {
+ windowContentView.addView(mPreviewPlacerView);
+ }
}
public void showGestureFloatingPreviewText(String gestureFloatingPreviewText) {