最近遇到一个淡疼的bug,banner与下拉刷新的ptr横向滑动冲突,
//左右滑动时刷新控件禁止掉
ptr.disableWhenHorizontalMove(true);
这样写有时候不好使,然后再加上重写ptr
public class PtrClassicRefreshLayout extends PtrClassicFrameLayout {
private boolean disallowInterceptTouchEvent = false;
public PtrClassicRefreshLayout(Context context) {
super(context);
}
public PtrClassicRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public PtrClassicRefreshLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
disallowInterceptTouchEvent = disallowIntercept;
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
@Override
public boolean dispatchTouchEvent(MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_UP:
//解除刷新的屏蔽
this.requestDisallowInterceptTouchEvent(false);
break;
}
if (disallowInterceptTouchEvent) {
//事件向下分发给子控件,子控件会屏蔽掉父控件的刷新
return dispatchTouchEventSupper(e);
}
return super.dispatchTouchEvent(e);
}
}