aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-10-24 22:25:37 +0900
committerJean Chalard <jchalard@google.com>2011-10-26 17:57:00 +0900
commitdec6c0f9290e90ba4da4719548a95440cc38d299 (patch)
tree4764028f8115781bf41c17d36b57ec3132078be0 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
parent720baf0cb3d6dcdf0b0024083824edaf905499ed (diff)
downloadlatinime-dec6c0f9290e90ba4da4719548a95440cc38d299.tar.gz
latinime-dec6c0f9290e90ba4da4719548a95440cc38d299.tar.xz
latinime-dec6c0f9290e90ba4da4719548a95440cc38d299.zip
DO NOT MERGE: Fix a bug where the sequence numbers would be wrong
The spell checker cannot afford to return static objects, seeing as the framework will then use the same objects to pair the cookie and sequence ids to the request. This is a backport of Ia9c3a933 Bug: 5503243 Change-Id: Ia9c3a933bfb30cf5525418b240ef60632d72c9d0
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 8f478f385..095c2c51c 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -61,11 +61,6 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
private static final int CAPITALIZE_ALL = 2; // All caps
private final static String[] EMPTY_STRING_ARRAY = new String[0];
- private final static SuggestionsInfo NOT_IN_DICT_EMPTY_SUGGESTIONS =
- new SuggestionsInfo(0, EMPTY_STRING_ARRAY);
- private final static SuggestionsInfo IN_DICT_EMPTY_SUGGESTIONS =
- new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY,
- EMPTY_STRING_ARRAY);
private final static Flag[] USE_FULL_EDIT_DISTANCE_FLAG_ARRAY;
static {
// See BinaryDictionary.java for an explanation of these flags
@@ -103,6 +98,15 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
return new AndroidSpellCheckerSession(this);
}
+ private static SuggestionsInfo getNotInDictEmptySuggestions() {
+ return new SuggestionsInfo(0, EMPTY_STRING_ARRAY);
+ }
+
+ private static SuggestionsInfo getInDictEmptySuggestions() {
+ return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY,
+ EMPTY_STRING_ARRAY);
+ }
+
private static class SuggestionsGatherer implements WordCallback {
public static class Result {
public final String[] mSuggestions;
@@ -408,9 +412,9 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
DictAndProximity dictInfo = null;
try {
dictInfo = mDictionaryPool.takeOrGetNull();
- if (null == dictInfo) return NOT_IN_DICT_EMPTY_SUGGESTIONS;
- return dictInfo.mDictionary.isValidWord(text) ? IN_DICT_EMPTY_SUGGESTIONS
- : NOT_IN_DICT_EMPTY_SUGGESTIONS;
+ if (null == dictInfo) return getNotInDictEmptySuggestions();
+ return dictInfo.mDictionary.isValidWord(text) ? getInDictEmptySuggestions()
+ : getNotInDictEmptySuggestions();
} finally {
if (null != dictInfo) {
if (!mDictionaryPool.offer(dictInfo)) {
@@ -445,7 +449,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
DictAndProximity dictInfo = null;
try {
dictInfo = mDictionaryPool.takeOrGetNull();
- if (null == dictInfo) return NOT_IN_DICT_EMPTY_SUGGESTIONS;
+ if (null == dictInfo) return getNotInDictEmptySuggestions();
dictInfo.mDictionary.getWords(composer, suggestionsGatherer,
dictInfo.mProximityInfo);
isInDict = dictInfo.mDictionary.isValidWord(text);
@@ -490,7 +494,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
throw e;
} else {
Log.e(TAG, "Exception while spellcheking: " + e);
- return NOT_IN_DICT_EMPTY_SUGGESTIONS;
+ return getNotInDictEmptySuggestions();
}
}
}