QMUI_Android icon indicating copy to clipboard operation
QMUI_Android copied to clipboard

QMUIContinuousNestedScrollLayout内点击事件在滑动后短暂失效

Open litao0621 opened this issue 3 years ago • 1 comments

运行环境

  • [x] 设备型号:如:一加 7t
  • [x] 设备系统版本:如 Android 10
  • [x] Gradle 版本:如 4.10.1
  • [x] QMUI Android 版本:2.0.0-alpha11

具体问题描述

QMUIContinuousNestedScrollLayoutdispatchTouchEvent方法中 在滑动状态IDLE之前对事件进行了拦截,但这个状态存在延迟的问题,就照成视觉上滑动已经停止了,但有短暂的时间内点击事件无法响应,看到有注释must stop scroll and not use the current down event,但不太明白为什么怎么做,尤其是在fling到顶部或底部,stopScroll后直接super.dispatchTouchEvent(down)释放down event会造成什么问题呢。

@Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            if(mCurrentScrollState != IQMUIContinuousNestedScrollCommon.SCROLL_STATE_IDLE){
                // must stop scroll and not use the current down event.
                // this is worked when topView scroll to bottomView or bottomView scroll to topView.
                stopScroll();
                mIsDismissDownEvent = true;
                mDismissDownY = ev.getY();
                if(mTouchSlap < 0){
                    mTouchSlap = ViewConfiguration.get(getContext()).getScaledTouchSlop();
                }
                return true;
            }
        } else if(ev.getAction() == MotionEvent.ACTION_MOVE && mIsDismissDownEvent){
            if(Math.abs(ev.getY() - mDismissDownY) > mTouchSlap){
                MotionEvent down = MotionEvent.obtain(ev);
                down.setAction(MotionEvent.ACTION_DOWN);
                down.offsetLocation(0, mDismissDownY - ev.getY());
                super.dispatchTouchEvent(down);
                down.recycle();
            }else{
                return true;
            }
        }
        mIsDismissDownEvent = false;
        return super.dispatchTouchEvent(ev);
    }

问题截图

可以使用demo QMUIContinuousNestedScrollLayout -> linearLayout + recyclerview fling到底部,然后点击item,一段时间内是没有响应的

litao0621 avatar Dec 23 '20 08:12 litao0621

我这边也是,滚动到底部之后首次QMUIContinuousNestedScrollLayout内容区域点击事件必失效 直接使用QMUI的demo测试也存在这个问题: linearLayout + recyclerview 滚到底部之后再上提一下,下次的点击事件就必失效了

zhangjianhd avatar May 10 '21 09:05 zhangjianhd