summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-10-01 07:54:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-01 07:54:47 +0000
commit0487290f0f474ed64b93ad7e305792547669c665 (patch)
treec44329b435c393f48cbb98ec6b56fd56ed053091 /java
parent108dad1491d44bf381fdb5d4f0767fb251f28522 (diff)
parentdbf5701ee0a4910898a34e0aa2ab7c5ea520d4ba (diff)
downloadandroid_packages_inputmethods_LatinIME-0487290f0f474ed64b93ad7e305792547669c665.tar.gz
android_packages_inputmethods_LatinIME-0487290f0f474ed64b93ad7e305792547669c665.tar.bz2
android_packages_inputmethods_LatinIME-0487290f0f474ed64b93ad7e305792547669c665.zip
Merge "Fix NPE in KeyboardParams"
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
index 1e1188bd0..71ce768a9 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParams.java
@@ -27,6 +27,9 @@ import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
public class KeyboardParams {
public KeyboardId mId;
public int mThemeId;
@@ -67,7 +70,7 @@ public class KeyboardParams {
public final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
public final KeyStylesSet mKeyStyles = new KeyStylesSet(mTextsSet);
- public KeysCache mKeysCache;
+ @Nullable public KeysCache mKeysCache;
public boolean mAllowRedundantMoreKeys;
public int mMostCommonKeyHeight = 0;
@@ -96,7 +99,7 @@ public class KeyboardParams {
clearHistogram();
}
- public void onAddKey(final Key newKey) {
+ public void onAddKey(@Nonnull final Key newKey) {
final Key key = (mKeysCache != null) ? mKeysCache.get(newKey) : newKey;
final boolean isSpacer = key.isSpacer();
if (isSpacer && key.getWidth() == 0) {
@@ -129,7 +132,10 @@ public class KeyboardParams {
mSortedKeys.clear();
for (final Key key : allKeys) {
final Key filteredKey = Key.removeRedundantMoreKeys(key, lettersOnBaseLayout);
- mSortedKeys.add(mKeysCache.replace(key, filteredKey));
+ if (mKeysCache != null) {
+ mKeysCache.replace(key, filteredKey);
+ }
+ mSortedKeys.add(filteredKey);
}
}