From 41c1f480287dd4348edcad1434cfcb77db594060 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 13 Jul 2011 17:25:25 -0700 Subject: [PATCH] Fix IndexOutOfBound exception Bug: 5011243 Change-Id: Iaaafa50b42e5155e3682132217d3e079a170ed89 --- java/src/com/android/inputmethod/latin/CandidateView.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index 54c430373..96225f2e9 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -245,7 +245,12 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo mTexts.clear(); for (int i = 0; i < count; i++) { final CharSequence suggestion = suggestions.getWord(i); - if (suggestion == null) continue; + if (suggestion == null) { + // Skip an empty suggestion, but we need to add a place-holder for it in order + // to avoid an exception in the loop in updateSuggestions(). + mTexts.add(""); + continue; + } final boolean isAutoCorrect = suggestions.mHasMinimalSuggestion && ((i == 1 && !suggestions.mTypedWordValid)