diff options
author | Yoshiki Iguchi <yoshiki@google.com> | 2015-10-15 13:34:41 +0900 |
---|---|---|
committer | Yoshiki Iguchi <yoshiki@google.com> | 2015-10-22 07:28:47 +0000 |
commit | 9582e151964be60457d4abd712857fb1e8a4586d (patch) | |
tree | 340d79f25a8c093c05095f5f0953ee4d2e6ae91b /core | |
parent | 809dcade9906001f6aa51a68aa783e20bb1d7c0d (diff) | |
download | frameworks_base-9582e151964be60457d4abd712857fb1e8a4586d.zip frameworks_base-9582e151964be60457d4abd712857fb1e8a4586d.tar.gz frameworks_base-9582e151964be60457d4abd712857fb1e8a4586d.tar.bz2 |
Fix crash on calling removeSelection with showing selection handlers
A crash occured on updating after calling removeSelection with showing
selection handlers. This was because some selection-handler code didn't
consider the case the selection index was -1 (-1 means there is no selection).
This patch fixes this crash.
Bug: 23299977
Change-Id: I736d315e073f773aec597522203015205a8da42b
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/widget/Editor.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index b0dcbb8..13c1937 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -4253,10 +4253,14 @@ public class Editor { positionAtCursorOffset(offset, false); } + /** + * @param offset Cursor offset. Must be in [-1, length]. + * @param parentScrolled If the parent has been scrolled or not. + */ @Override protected void positionAtCursorOffset(int offset, boolean parentScrolled) { super.positionAtCursorOffset(offset, parentScrolled); - mInWord = !getWordIteratorWithText().isBoundary(offset); + mInWord = (offset != -1) && !getWordIteratorWithText().isBoundary(offset); } @Override @@ -4489,10 +4493,14 @@ public class Editor { positionAtCursorOffset(offset, false); } + /** + * @param offset Cursor offset. Must be in [-1, length]. + * @param parentScrolled If the parent has been scrolled or not. + */ @Override protected void positionAtCursorOffset(int offset, boolean parentScrolled) { super.positionAtCursorOffset(offset, parentScrolled); - mInWord = !getWordIteratorWithText().isBoundary(offset); + mInWord = (offset != -1) && !getWordIteratorWithText().isBoundary(offset); } @Override |