diff options
author | 2010-09-28 09:45:45 +0900 | |
---|---|---|
committer | 2010-09-28 10:15:55 +0900 | |
commit | 8bfcac4d84ffcfd36f68bf42c179b2b46dd7462c (patch) | |
tree | 1d988d4ae98b05217b75b553cc1c6d256ecc91b4 /java | |
parent | 1571a660d8a769c57cdc698368afe666a184bde1 (diff) | |
download | latinime-8bfcac4d84ffcfd36f68bf42c179b2b46dd7462c.tar.gz latinime-8bfcac4d84ffcfd36f68bf42c179b2b46dd7462c.tar.xz latinime-8bfcac4d84ffcfd36f68bf42c179b2b46dd7462c.zip |
Fix NPE in LatinKeyboard when it represent phone keyboard
Bug: 3041532
Change-Id: I1d846e9175bd033f056a8715287a936be2fe8f74
Diffstat (limited to 'java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinKeyboard.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 9e24ee322..76b90f8f3 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -158,9 +158,22 @@ public class LatinKeyboard extends Keyboard { mNumberHintIcons[9] = res.getDrawable(R.drawable.keyboard_hint_9); } + // TODO: delete this method and do initialization in constructor. + private void initializeMemberVariablesAsNeeded() { + if (mNumberHintKeys == null) + mNumberHintKeys = new Key[NUMBER_HINT_COUNT]; + if (mShiftKeys == null) + mShiftKeys = new ArrayList<Key>(); + } + @Override protected Key createKeyFromXml(Resources res, Row parent, int x, int y, XmlResourceParser parser) { + // TODO: This initialization is needed because this protected method is being called from + // the base class constructor before this class constructor gets called. We need to fix + // this. + initializeMemberVariablesAsNeeded(); + Key key = new LatinKey(res, parent, x, y, parser); switch (key.codes[0]) { case LatinIME.KEYCODE_ENTER: @@ -173,10 +186,6 @@ public class LatinKeyboard extends Keyboard { mSpaceKey = key; break; case KEYCODE_SHIFT: - // NOTE: This protected method is being called from the base class constructor before - // mShiftKeys gets initialized. - if (mShiftKeys == null) - mShiftKeys = new ArrayList<Key>(); mShiftKeys.add(key); break; case KEYCODE_MODE_CHANGE: @@ -186,11 +195,6 @@ public class LatinKeyboard extends Keyboard { } // For number hints on the upper-right corner of key - if (mNumberHintKeys == null) { - // NOTE: This protected method is being called from the base class constructor before - // mNumberHintKeys gets initialized. - mNumberHintKeys = new Key[NUMBER_HINT_COUNT]; - } int hintNumber = -1; if (LatinKeyboardBaseView.isNumberAtLeftmostPopupChar(key)) { hintNumber = key.popupCharacters.charAt(0) - '0'; |