Skip to content
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

[fix] 修复在数据非常少的时候的滑动卡顿 #987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions wheelview/src/main/java/com/contrarywind/view/WheelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean eventConsumed = gestureDetector.onTouchEvent(event);
boolean isIgnore = false;//超过边界滑动时,不再绘制UI。

float top = -initPosition * itemHeight;
float bottom = (adapter.getItemsCount() - 1 - initPosition) * itemHeight;
float ratio = 0.25f;

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Expand All @@ -690,13 +687,10 @@ public boolean onTouchEvent(MotionEvent event) {

// normal mode。
if (!isLoop) {
if ((totalScrollY - itemHeight * ratio < top && dy < 0)
|| (totalScrollY + itemHeight * ratio > bottom && dy > 0)) {
//快滑动到边界了,设置已滑动到边界的标志
totalScrollY -= dy;
isIgnore = true;
} else {
isIgnore = false;
if (totalScrollY < top) {
totalScrollY = (int) top;
} else if (totalScrollY > bottom) {
totalScrollY = (int) bottom;
}
}
break;
Expand Down Expand Up @@ -735,7 +729,7 @@ public boolean onTouchEvent(MotionEvent event) {
}
break;
}
if (!isIgnore && event.getAction() != MotionEvent.ACTION_DOWN) {
if (event.getAction() != MotionEvent.ACTION_DOWN) {
invalidate();
}
return true;
Expand Down