Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Fix java NRE handing touch events on detached view #1571

Merged
merged 2 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
* [iOS(iPad)] `ComboBox` : the combobox wasn't fully expanding vertically on first opening.
* `Popup` & `ComboBox` (and other controls using `Popup`) were not behaving properly when `IsLightDismissable` were set to `true`.
* [Wasm] Fix unloaded UIElements are made visible if measured and arranged
* [Android] Fix java NRE handing touch events on detached view

## Release 1.45.0
### Features
Expand Down
21 changes: 13 additions & 8 deletions src/Uno.UI.BindingHelper.Android/Uno/UI/UnoViewGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,19 @@ private static float[] getTransformedTouchCoordinate(ViewParent view, MotionEven
return point;
}

// Non-UIElement view, walk the tree up to the next UIElement
// (and adjust coordinate for each layer to include its location, i.e. Top, Left, etc.)
final ViewParent parent = view.getParent();
if (parent instanceof View) {
// Not at root, walk upward
float[] coords = getTransformedTouchCoordinate(parent, e);
calculateTransformedPoint((View) view, coords);
return coords;
if(view != null) {
// The parent view may be null if the touched item is being removed
// from the tree while being touched.

// Non-UIElement view, walk the tree up to the next UIElement
// (and adjust coordinate for each layer to include its location, i.e. Top, Left, etc.)
final ViewParent parent = view.getParent();
if (parent instanceof View) {
// Not at root, walk upward
float[] coords = getTransformedTouchCoordinate(parent, e);
calculateTransformedPoint((View) view, coords);
return coords;
}
}

// We reached the top of the tree
Expand Down