Callback for Android spell check API that decomposes results and send results through the SpellCheckChannel
.
where there may be up to 5 suggestions.
125 {
126 if (results.length == 0) {
127 pendingResult.success(
new ArrayList<HashMap<String, Object>>());
129 return;
130 }
131
132 ArrayList<HashMap<String, Object>> spellCheckerSuggestionSpans =
133 new ArrayList<HashMap<String, Object>>();
134 SentenceSuggestionsInfo spellCheckResults = results[0];
135 if (spellCheckResults == null) {
136 pendingResult.success(
new ArrayList<HashMap<String, Object>>());
138 return;
139 }
140
141 for (int i = 0; i < spellCheckResults.getSuggestionsCount(); i++) {
142 SuggestionsInfo suggestionsInfo = spellCheckResults.getSuggestionsInfoAt(i);
143 int suggestionsCount = suggestionsInfo.getSuggestionsCount();
144
145 if (suggestionsCount <= 0) {
146 continue;
147 }
148
149 HashMap<String, Object> spellCheckerSuggestionSpan = new HashMap<String, Object>();
150 int start = spellCheckResults.getOffsetAt(i);
151 int end =
start + spellCheckResults.getLengthAt(i);
152
155
156 ArrayList<String> suggestions = new ArrayList<String>();
157 boolean validSuggestionsFound = false;
158 for (int j = 0; j < suggestionsCount; j++) {
159 String suggestion = suggestionsInfo.getSuggestionAt(j);
160
161
162 if (!suggestion.equals("")) {
163 validSuggestionsFound = true;
164 suggestions.add(suggestion);
165 }
166 }
167
168 if (!validSuggestionsFound) {
169 continue;
170 }
172 spellCheckerSuggestionSpans.add(spellCheckerSuggestionSpan);
173 }
174
177 }
static final String SUGGESTIONS_KEY
static final String START_INDEX_KEY
static final String END_INDEX_KEY