-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
加载更多,执行两次或更多,什么原因 #56
Comments
我也碰到这个问题,原因是刷新耗时比较短,在上拉动作还没结束的时候就完成了,此时的上拉动作触发了下一次刷新. @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isRefreshing) return true;
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouchY = ev.getY();
mCurrentY = mTouchY;
break;
case MotionEvent.ACTION_MOVE:
float currentY = ev.getY();
float dy = currentY - mTouchY;
if (dy > 0 && !canChildScrollUp()) {
if (mMaterialHeaderView != null) {
mMaterialHeaderView.setVisibility(View.VISIBLE);
mMaterialHeaderView.onBegin(this);
} else if (mSunLayout != null) {
mSunLayout.setVisibility(View.VISIBLE);
mSunLayout.onBegin(this);
}
return true;
} else if (dy < 0 && !canChildScrollDown() && isLoadMore) {
if (mMaterialFooterView != null && !isLoadMoreing) {
soveLoadMoreLogic();
}
return super.onInterceptTouchEvent(ev);
}
break;
}
return super.onInterceptTouchEvent(ev);
} 解决: 将事件派发的逻辑放到 @Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isRefreshing) return true;
float currentY = ev.getY();
float dy = currentY - mTouchY;
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
mTouchY = ev.getY();
mCurrentY = mTouchY;
break;
case MotionEvent.ACTION_UP:
if (dy < 0 && !canChildScrollDown() && isLoadMore) {
if (mMaterialFooterView != null && !isLoadMoreing) {
soveLoadMoreLogic();
}
return super.onInterceptTouchEvent(ev);
}
break;
case MotionEvent.ACTION_MOVE:
if (dy > 0 && !canChildScrollUp()) {
if (mMaterialHeaderView != null) {
mMaterialHeaderView.setVisibility(View.VISIBLE);
mMaterialHeaderView.onBegin(this);
} else if (mSunLayout != null) {
mSunLayout.setVisibility(View.VISIBLE);
mSunLayout.onBegin(this);
}
return true;
}
break;
}
return super.onInterceptTouchEvent(ev);
} |
我也遇到了,列表一碰就触发加载更多 :#67 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
加载更多,执行两次或更多,什么原因
The text was updated successfully, but these errors were encountered: