Filter touch events in ExpandableView.

Because the actual height is the different as the laid out one, we
need to filter the touch events here.

Change-Id: I6abd3fb0fffe275c2b83e7c48df1dd866499a28c
This commit is contained in:
Jorim Jaggi
2014-05-02 17:29:56 +02:00
parent 59b5a356b8
commit 00ebdfe8ba

View File

@@ -23,6 +23,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
@@ -49,6 +50,19 @@ public abstract class ExpandableView extends FrameLayout {
mActualHeightInitialized = true;
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (filterMotionEvent(ev)) {
return super.dispatchTouchEvent(ev);
}
return false;
}
private boolean filterMotionEvent(MotionEvent event) {
return event.getActionMasked() != MotionEvent.ACTION_DOWN
|| event.getY() > mClipTopAmount && event.getY() < mActualHeight;
}
/**
* Sets the actual height of this notification. This is different than the laid out
* {@link View#getHeight()}, as we want to avoid layouting during scrolling and expanding.