Filter out detached views from touch
Views that are detached shouldn't get touch events/start getting
animated (They can't be animated).
Added filter to stream to remove these views from consideration for the
nearest touch frame algo.
Test: Visually + unit test
Bug: 65146195
Change-Id: I74df495a7c02d3d46cd6784f0950c48b5311819e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java
index 1452e0c..e5083c1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java
@@ -95,8 +95,12 @@
}
private View findNearestChild(MotionEvent event) {
- return mClickableChildren.stream().map(v -> new Pair<>(distance(v, event), v))
- .min(Comparator.comparingInt(f -> f.first)).get().second;
+ return mClickableChildren
+ .stream()
+ .filter(v -> v.isAttachedToWindow())
+ .map(v -> new Pair<>(distance(v, event), v))
+ .min(Comparator.comparingInt(f -> f.first))
+ .get().second;
}
private int distance(View v, MotionEvent event) {