fix scroll end callback time
This commit is contained in:
parent
f693719974
commit
77281b945f
@ -198,6 +198,7 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
private float mVerticalScrollFactor;
|
private float mVerticalScrollFactor;
|
||||||
|
|
||||||
private OnScrollChangeListener mOnScrollChangeListener;
|
private OnScrollChangeListener mOnScrollChangeListener;
|
||||||
|
private boolean mInTouch = false;
|
||||||
|
|
||||||
public HVScrollView(Context context) {
|
public HVScrollView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@ -692,9 +693,6 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mScrollState = state;
|
mScrollState = state;
|
||||||
if (state == SCROLL_STATE_IDLE && mOnScrollChangeListener != null) {
|
|
||||||
mOnScrollChangeListener.onScrollEnd(this, getScrollX(), getScrollY());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelTouch() {
|
private void cancelTouch() {
|
||||||
@ -895,7 +893,7 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
|
|
||||||
switch (actionMasked) {
|
switch (actionMasked) {
|
||||||
case MotionEvent.ACTION_DOWN: {
|
case MotionEvent.ACTION_DOWN: {
|
||||||
|
mInTouch = true;
|
||||||
/*
|
/*
|
||||||
* If being flinged and user touches, stop the fling. isFinished
|
* If being flinged and user touches, stop the fling. isFinished
|
||||||
* will be false if being flinged.
|
* will be false if being flinged.
|
||||||
@ -920,6 +918,8 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
mInTouch = true;
|
||||||
|
|
||||||
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
final int activePointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||||
if (activePointerIndex == -1) {
|
if (activePointerIndex == -1) {
|
||||||
Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
|
Log.e(TAG, "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
|
||||||
@ -1041,6 +1041,8 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
|
mInTouch = false;
|
||||||
|
|
||||||
final VelocityTracker velocityTracker = mVelocityTracker;
|
final VelocityTracker velocityTracker = mVelocityTracker;
|
||||||
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
|
||||||
|
|
||||||
@ -1058,6 +1060,8 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
resetTouch();
|
resetTouch();
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_CANCEL:
|
case MotionEvent.ACTION_CANCEL:
|
||||||
|
mInTouch = false;
|
||||||
|
|
||||||
if (mScrollState == SCROLL_STATE_DRAGGING) {
|
if (mScrollState == SCROLL_STATE_DRAGGING) {
|
||||||
if (mScroller.springBack(getScrollX(), getScrollY(), 0, getScrollRangeX(), 0, getScrollRangeY())) {
|
if (mScroller.springBack(getScrollX(), getScrollY(), 0, getScrollRangeX(), 0, getScrollRangeY())) {
|
||||||
ViewCompat.postInvalidateOnAnimation(this);
|
ViewCompat.postInvalidateOnAnimation(this);
|
||||||
@ -1998,6 +2002,11 @@ public class HVScrollView extends FrameLayout implements NestedScrollingParent,
|
|||||||
ViewCompat.postInvalidateOnAnimation(this);
|
ViewCompat.postInvalidateOnAnimation(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mScroller.isFinished() && !mInTouch) {
|
||||||
|
if (mOnScrollChangeListener != null) {
|
||||||
|
mOnScrollChangeListener.onScrollEnd(HVScrollView.this, getScrollX(), getScrollY());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user