Skip to content

Commit

Permalink
Added experimental support for nested layout or touch focusable view …
Browse files Browse the repository at this point in the history
…ripples #12 #26
  • Loading branch information
balysv committed Jan 31, 2015
1 parent 0483d16 commit debf326
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void setOnClickListener(OnClickListener onClickListener) {

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return true;
return !findClickableViewInChild(childView, (int) event.getX(), (int) event.getY());
}

@Override
Expand Down Expand Up @@ -426,6 +426,26 @@ private boolean adapterPositionChanged() {
return false;
}

private boolean findClickableViewInChild(View view, int x, int y) {
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
final Rect rect = new Rect();
child.getHitRect(rect);

final boolean contains = rect.contains(x, y);
if (contains) {
return findClickableViewInChild(child, x - rect.left, y - rect.top);
}
}
} else if (view != childView) {
return (view.isEnabled() && (view.isClickable() || view.isLongClickable() || view.isFocusableInTouchMode()));
}

return view.isFocusableInTouchMode();
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
Expand Down

0 comments on commit debf326

Please sign in to comment.