summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ViewRoot.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 57768515ad48..1e3cdb34f436 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1374,6 +1374,15 @@ public final class ViewRoot extends Handler implements ViewParent,
// is non-null and we just want to scroll to whatever that
// rectangle is).
View focus = mRealFocusedView;
+
+ // When in touch mode, focus points to the previously focused view,
+ // which may have been removed from the view hierarchy. The following
+ // line checks whether the view is still in the hierarchy
+ if (focus == null || focus.getParent() == null) {
+ mRealFocusedView = null;
+ return false;
+ }
+
if (focus != mLastScrolledFocus) {
// If the focus has changed, then ignore any requests to scroll
// to a rectangle; first we want to make sure the entire focus