You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you consider changing the way the library dispatches the click to the leaf nodes only by instead checking if non-leaf nodes have a click listener attached and giving priority to those?
This means that if i have a ViewGroup with a click listener and some items inside, everywhere i lift my finger in this view group, the click will be dispatched to the view group instead of the children.
Alternatively we can also inject this behavior and make it custmizable.
Happy to open a PR for this and contribute just let me know what you think.
The text was updated successfully, but these errors were encountered:
My proposal would be to change this method like below:
private void dispatchClickToLeafsOnly(ViewGroup view, MotionEvent motionEvent) {
// If no view or no children, return
if (view == null || view.getChildCount() == 0) {
return;
}
for (int i = 0; i < view.getChildCount(); i++) {
View child = view.getChildAt(i);
if (child instanceof ViewGroup && !child.hasOnClickListeners()) {
// If a ViewGroup without click listener, search for leafs inside
dispatchClickToLeafsOnly((ViewGroup) child, motionEvent);
} else {
// Else check if touch event is inside it
if (LongPressPopupUtils.isTouchInsideView(child, motionEvent)) {
if (mLongPressReleaseClickListener != null) {
// Notify the given listener
mLongPressReleaseClickListener.onClick(child);
} else {
// Else, dispatch the touch event on the view
child.performClick();
}
} else if (child instanceof ViewGroup) {
// If a ViewGroup without click listener, search for leafs inside
dispatchClickToLeafsOnly((ViewGroup) child, motionEvent);
}
}
}
}
Would you consider changing the way the library dispatches the click to the leaf nodes only by instead checking if non-leaf nodes have a click listener attached and giving priority to those?
This means that if i have a ViewGroup with a click listener and some items inside, everywhere i lift my finger in this view group, the click will be dispatched to the view group instead of the children.
Alternatively we can also inject this behavior and make it custmizable.
Happy to open a PR for this and contribute just let me know what you think.
The text was updated successfully, but these errors were encountered: