From 37deb112c727dfed5e94d054cf5f00f5d60c8120 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Fri, 10 Jun 2011 09:53:27 +0900 Subject: [PATCH] Fix IndexOutOfBoundsException Bug: 4586181 Change-Id: I10a2d1486c9a0d11aa42cf7c6a33ecd70b6918d7 --- .../com/android/inputmethod/latin/CandidateView.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index 5719b9012..c52f6b2c4 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -332,8 +332,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo @Override public boolean onLongClick(View view) { - int index = (Integer) view.getTag(); - CharSequence word = mSuggestions.getWord(index); + final int index = (Integer) view.getTag(); + if (index >= mSuggestions.size()) + return true; + final CharSequence word = mSuggestions.getWord(index); if (word.length() < 2) return false; addToDictionary(word); @@ -342,8 +344,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo @Override public void onClick(View view) { - int index = (Integer) view.getTag(); - CharSequence word = mSuggestions.getWord(index); + final int index = (Integer) view.getTag(); + if (index >= mSuggestions.size()) + return; + final CharSequence word = mSuggestions.getWord(index); if (mShowingAddToDictionary && index == 0) { addToDictionary(word); } else {