Skip to content

Commit

Permalink
修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
donkingliang committed Feb 8, 2023
1 parent be776bd commit 77d0239
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
scrollerLayout.setOnVerticalScrollChangeListener(new ConsecutiveScrollerLayout.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollY, int oldScrollY, int scrollState) {
if (scrollY > flSink.getHeight()){
if (scrollY > flSink.getHeight() || scrollY < 0){
scrollerLayout.setStickyOffset(0); // 恢复吸顶偏移量
} else {
// 通过设置吸顶便宜量,实现flSink滑动隐藏时的向上移动效果
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ public float getInterpolation(float t) {
*/
private boolean isTouchNotTriggerScrollStick = false;

/**
* 判断手指触摸的view是否需要拦截事件
*/
private boolean isIntercept = false;

/**
* 在快速滑动的过程中,触摸停止滑动
*/
Expand Down Expand Up @@ -647,6 +652,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {

mDownLocation[0] = ScrollUtils.getRawX(this, ev, actionIndex);
mDownLocation[1] = ScrollUtils.getRawY(this, ev, actionIndex);
isIntercept = isIntercept(mDownLocation[0], mDownLocation[1]);
isTouchNotTriggerScrollStick = ScrollUtils.isTouchNotTriggerScrollStick(this, mDownLocation[0], mDownLocation[1]);
break;
case MotionEvent.ACTION_POINTER_DOWN:
Expand All @@ -658,6 +664,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
requestDisallowInterceptTouchEvent(false);
mDownLocation[0] = ScrollUtils.getRawX(this, ev, actionIndex);
mDownLocation[1] = ScrollUtils.getRawY(this, ev, actionIndex);
isIntercept = isIntercept(mDownLocation[0], mDownLocation[1]);
isTouchNotTriggerScrollStick = ScrollUtils.isTouchNotTriggerScrollStick(this, mDownLocation[0], mDownLocation[1]);

initAdjustVelocityTrackerIfNotExists();
Expand All @@ -677,7 +684,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
int offsetY = (int) ev.getY(pointerIndex) - mEventY;
int offsetX = (int) ev.getX(pointerIndex) - mEventX;
if (SCROLL_ORIENTATION == SCROLL_NONE
&& (isIntercept(ev) || isIntercept(mDownLocation[0], mDownLocation[1]))) {
&& (isIntercept || isIntercept(ev))) {
if (disableChildHorizontalScroll) {
if (Math.abs(offsetY) >= mTouchSlop) {
SCROLL_ORIENTATION = SCROLL_VERTICAL;
Expand Down Expand Up @@ -723,6 +730,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
mEventX = (int) ev.getX(newPointerIndex);
mDownLocation[0] = ScrollUtils.getRawX(this, ev, newPointerIndex);
mDownLocation[1] = ScrollUtils.getRawY(this, ev, newPointerIndex);
isIntercept = isIntercept(mDownLocation[0], mDownLocation[1]);
isTouchNotTriggerScrollStick = ScrollUtils.isTouchNotTriggerScrollStick(this, mDownLocation[0], mDownLocation[1]);
}
initAdjustVelocityTrackerIfNotExists();
Expand Down Expand Up @@ -767,6 +775,7 @@ && isIntercept(ev) && Math.abs(yVelocity) >= mMinimumVelocity) {
mDownLocation[0] = 0;
mDownLocation[1] = 0;
isTouchNotTriggerScrollStick = false;
isIntercept = false;
overSpinner();
break;
}
Expand Down Expand Up @@ -803,7 +812,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {

// 需要拦截事件
if (SCROLL_ORIENTATION != SCROLL_HORIZONTAL
&& (isIntercept(ev) || isIntercept(mDownLocation[0], mDownLocation[1]))) {
&& (isIntercept || isIntercept(ev))) {
return true;
}
break;
Expand Down

0 comments on commit 77d0239

Please sign in to comment.