summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-09-23 10:56:24 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2011-09-26 15:59:24 -0700
commit14ed50a9a3386e63ee19f6ac0b66c7f3c0fe362a (patch)
treef1290960d1c44582c4971a1f4d6702abc4da95c5 /core
parenta6ccaa736d18d1ee375162e9df9d2aad8db869e5 (diff)
downloadframeworks_base-14ed50a9a3386e63ee19f6ac0b66c7f3c0fe362a.zip
frameworks_base-14ed50a9a3386e63ee19f6ac0b66c7f3c0fe362a.tar.gz
frameworks_base-14ed50a9a3386e63ee19f6ac0b66c7f3c0fe362a.tar.bz2
Bug 5332065: IOOB in case the suggestionSpan has been removed
I don't understand how the SuggSpan that has been tapped to display the popup can have disappeared when an item is clicked. This problem seems specific to monkey test with a race condition somewhere. Change-Id: I447b6563a1b959dc3c1ead31cde2d9bcad369765
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/TextView.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d680f36..e1f94ac 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -9879,6 +9879,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ hide();
+
if (view instanceof TextView) {
TextView textView = (TextView) view;
Editable editable = (Editable) mText;
@@ -9886,6 +9888,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
SuggestionInfo suggestionInfo = mSuggestionInfos[position];
final int spanStart = editable.getSpanStart(suggestionInfo.suggestionSpan);
final int spanEnd = editable.getSpanEnd(suggestionInfo.suggestionSpan);
+ if (spanStart < 0 || spanEnd < 0) return; // Span has been removed
final String originalText = mText.subSequence(spanStart, spanEnd).toString();
if (suggestionInfo.suggestionIndex < 0) {
@@ -9947,7 +9950,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
Selection.setSelection(editable, spanEnd + lengthDifference);
}
}
- hide();
}
}