Fix a NPE in DistracterFilter.isDistracterToWordsInDictionaries()

Bug: 14904706
Change-Id: I3b52bb01b9c59cbba2eba0bd1d91dffb4419c019
main
Xiaojun Bi 2014-05-13 20:43:15 -07:00 committed by The Android Automerger
parent 15531c49f5
commit a2692d9bf2
1 changed files with 2 additions and 7 deletions

View File

@ -90,19 +90,14 @@ public class DistracterFilter {
*/
public boolean isDistracterToWordsInDictionaries(final String prevWord,
final String testedWord) {
if (mSuggest == null) {
if (mSuggest == null || mKeyboard == null) {
return false;
}
final WordComposer composer = new WordComposer();
final int[] codePoints = StringUtils.toCodePointArray(testedWord);
final int[] coordinates;
if (null == mKeyboard) {
coordinates = CoordinateUtils.newCoordinateArray(codePoints.length,
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
} else {
coordinates = mKeyboard.getCoordinates(codePoints);
}
coordinates = mKeyboard.getCoordinates(codePoints);
composer.setComposingWord(codePoints, coordinates, prevWord);
final int trailingSingleQuotesCount = composer.trailingSingleQuotesCount();