android-Ultra-Pull-To-Refresh icon indicating copy to clipboard operation
android-Ultra-Pull-To-Refresh copied to clipboard

跟viewpager的轮播图使用,手势冲突太严重了,无法解决。

Open itsgm opened this issue 7 years ago • 3 comments

查了一堆屏蔽事件的,没有用,按照作者的设置一行代码也无明显效果。

itsgm avatar Jul 19 '17 09:07 itsgm

已找到解决方法 在阅读了android-Ultra-Pull-To-Refresh的PtrFramLayout源码后发现修改了这个bug,这里直接提供修改方法,我们打开PtrFramLayout.Java这个类,找到308行代码: if (mDisableWhenHorizontalMove && !mPreventForHorizontal && (Math.abs(offsetX) > mPagingTouchSlop && Math.abs(offsetX) > Math.abs(offsetY))) { if (mPtrIndicator.isInStartPosition()) { mPreventForHorizontal = true; } } 把上述代码的if判断的Math.abs(offsetX) > mPagingTouchSlop这一句去掉就可以了,完整代码如下:

if (mDisableWhenHorizontalMove && !mPreventForHorizontal && Math.abs(offsetX) > Math.abs(offsetY)) { if (mPtrIndicator.isInStartPosition()) { mPreventForHorizontal = true; } 原因是,我们既然要禁用横向滑动的拦截,那么判断操作为横向并且要禁用横向拦截时给mPreventForHorizontal赋值为true即可,并不需要判断滑动距离。 同时PtrFramLayout的第113、114行代码就无用了,可以注释了,第54行mPagingTouchSlop成员变量也无用,可以注释了。 使用的同学请注意还是需要调用PtrFrameLayout.disableWhenHorizontalMove(true)来灵活控制是否需要拦截。

itsgm avatar Jul 19 '17 10:07 itsgm

我也很郁闷,直接代码设置成true还是一样,难道他们就没测过吗

weimingjue avatar Aug 11 '17 05:08 weimingjue

换库吧,有个新的库很强大,不冲突。https://github.com/scwang90/SmartRefreshLayout

------------------ 原始邮件 ------------------ 发件人: "weimingjue";[email protected]; 发送时间: 2017年8月11日(星期五) 中午1:27 收件人: "liaohuqiu/android-Ultra-Pull-To-Refresh"[email protected]; 抄送: "明"[email protected]; "Author"[email protected]; 主题: Re: [liaohuqiu/android-Ultra-Pull-To-Refresh] 跟viewpager的轮播图使用,手势冲突太严重了,无法解决。 (#312)

我也很郁闷,直接代码设置成true还是一样,难道他们就没测过吗

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

itsgm avatar Aug 11 '17 12:08 itsgm