Fix IndexOutOfBoundsException

Bug: 4586181
Change-Id: I10a2d1486c9a0d11aa42cf7c6a33ecd70b6918d7
main
Tadashi G. Takaoka 2011-06-10 09:53:27 +09:00
parent 98275e4512
commit 37deb112c7
1 changed files with 8 additions and 4 deletions

View File

@ -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 {