From d4bb0b01c6caccbaef1baec377a59c10790da35c Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Fri, 27 May 2011 15:58:55 -0700 Subject: Fix for bug 4499752 - Detect nulled layouts in HandleViews Change-Id: I6a7289150bf461cdf4cca0aff4aa4a0400e0d553 --- core/java/android/text/method/WordIterator.java | 3 ++- core/java/android/widget/TextView.java | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'core/java') diff --git a/core/java/android/text/method/WordIterator.java b/core/java/android/text/method/WordIterator.java index b250414..af524ee 100644 --- a/core/java/android/text/method/WordIterator.java +++ b/core/java/android/text/method/WordIterator.java @@ -213,7 +213,8 @@ public class WordIterator implements Selection.PositionIterator { private void checkOffsetIsValid(int offset) { if (offset < 0 || offset > mCurrent.length()) { - final String message = "Valid range is [0, " + mCurrent.length() + "]"; + final String message = "Invalid offset: " + offset + + ". Valid range is [0, " + mCurrent.length() + "]"; throw new IllegalArgumentException(message); } } diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 3875765..8835a04 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -9140,6 +9140,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener public abstract void updatePosition(float x, float y); protected void positionAtCursorOffset(int offset) { + // A HandleView relies on the layout, which may be nulled by external methods. + if (mLayout == null) { + // Will update controllers' state, hiding them and stopping selection mode if needed + prepareCursorControllers(); + return; + } + addPositionToTouchUpFilter(offset); final int line = mLayout.getLineForOffset(offset); final int lineBottom = mLayout.getLineBottom(line); -- cgit v1.1