@@ -427,12 +427,6 @@ private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo s
427427 if (spellCheckSpanStart < 0 || spellCheckSpanEnd <= spellCheckSpanStart )
428428 return ; // span was removed in the meantime
429429
430- final int suggestionsCount = suggestionsInfo .getSuggestionsCount ();
431- if (suggestionsCount <= 0 ) {
432- // A negative suggestion count is possible
433- return ;
434- }
435-
436430 final int start ;
437431 final int end ;
438432 if (offset != USE_SPAN_RANGE && length != USE_SPAN_RANGE ) {
@@ -443,17 +437,23 @@ private void createMisspelledSuggestionSpan(Editable editable, SuggestionsInfo s
443437 end = spellCheckSpanEnd ;
444438 }
445439
446- String [] suggestions = new String [suggestionsCount ];
447- for (int i = 0 ; i < suggestionsCount ; i ++) {
448- suggestions [i ] = suggestionsInfo .getSuggestionAt (i );
440+ final int suggestionsCount = suggestionsInfo .getSuggestionsCount ();
441+ String [] suggestions ;
442+ if (suggestionsCount > 0 ) {
443+ suggestions = new String [suggestionsCount ];
444+ for (int i = 0 ; i < suggestionsCount ; i ++) {
445+ suggestions [i ] = suggestionsInfo .getSuggestionAt (i );
446+ }
447+ } else {
448+ suggestions = ArrayUtils .emptyArray (String .class );
449449 }
450450
451451 SuggestionSpan suggestionSpan = new SuggestionSpan (mTextView .getContext (), suggestions ,
452452 SuggestionSpan .FLAG_EASY_CORRECT | SuggestionSpan .FLAG_MISSPELLED );
453453 // TODO: Remove mIsSentenceSpellCheckSupported by extracting an interface
454454 // to share the logic of word level spell checker and sentence level spell checker
455455 if (mIsSentenceSpellCheckSupported ) {
456- final long key = TextUtils .packRangeInLong (start , end );
456+ final Long key = Long . valueOf ( TextUtils .packRangeInLong (start , end ) );
457457 final SuggestionSpan tempSuggestionSpan = mSuggestionSpanCache .get (key );
458458 if (tempSuggestionSpan != null ) {
459459 if (DBG ) {
0 commit comments