Filter hover events for clipped views

Fixes a bug where hovering would select a view even
if the hovered part was clipped away.

Bug: 21763049
Change-Id: I1bbe700cf15d467d570a16bf474e62a477e4bb51
This commit is contained in:
Adrian Roos
2015-06-10 17:47:12 -07:00
parent cd55f43db6
commit e0c1890bdc

View File

@@ -132,6 +132,14 @@ public abstract class ExpandableView extends FrameLayout {
return getHeight();
}
@Override
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
if (filterMotionEvent(ev)) {
return super.dispatchGenericMotionEvent(ev);
}
return false;
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (filterMotionEvent(ev)) {
@@ -142,6 +150,8 @@ public abstract class ExpandableView extends FrameLayout {
protected boolean filterMotionEvent(MotionEvent event) {
return event.getActionMasked() != MotionEvent.ACTION_DOWN
&& event.getActionMasked() != MotionEvent.ACTION_HOVER_ENTER
&& event.getActionMasked() != MotionEvent.ACTION_HOVER_MOVE
|| event.getY() > mClipTopAmount && event.getY() < mActualHeight;
}
@@ -343,6 +353,7 @@ public abstract class ExpandableView extends FrameLayout {
public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
super.getBoundsOnScreen(outRect, clipToParent);
outRect.bottom = (int) (outRect.top + getActualHeight());
outRect.top += getClipTopAmount();
}
public int getContentHeight() {