@@ -39,7 +39,8 @@ public void computeScroll() {
3939
4040 private int currentIndex = -1 ;
4141
42- private void doScroll (int distance ) {
42+ private boolean doScroll (int distance ) {
43+ int scrollOffset = mScrollOffset ;
4344 mScrollOffset += distance ;
4445 if (!mWheelView .isCyclic ()) {
4546 // 限制滚动边界
@@ -50,7 +51,11 @@ private void doScroll(int distance) {
5051 mScrollOffset = maxOffset ;
5152 }
5253 }
53- notifyWheelChangedListener ();
54+ if (mScrollOffset != scrollOffset ) {
55+ notifyWheelChangedListener ();
56+ return true ;
57+ }
58+ return false ;
5459 }
5560
5661 void notifyWheelChangedListener () {
@@ -91,8 +96,9 @@ public void setCurrentIndex(int index, boolean animated) {
9196 startScroll (0 , mScrollOffset , 0 , distance , JUSTIFY_DURATION );
9297 mWheelView .invalidate ();
9398 } else {
94- doScroll (distance );
95- mWheelView .invalidate ();
99+ if (doScroll (distance )) {
100+ mWheelView .invalidate ();
101+ }
96102 }
97103 }
98104
@@ -147,13 +153,17 @@ public boolean onTouchEvent(MotionEvent event) {
147153 case MotionEvent .ACTION_DOWN :
148154 lastTouchY = event .getY ();
149155 forceFinished (true );
156+ mWheelView .getParent ().requestDisallowInterceptTouchEvent (true );
150157 break ;
151158 case MotionEvent .ACTION_MOVE :
152159 float touchY = event .getY ();
153160 int deltaY = (int ) (touchY - lastTouchY );
154161 if (deltaY != 0 ) {
155- doScroll (-deltaY );
156- mWheelView .invalidate ();
162+ if (doScroll (-deltaY )) {
163+ mWheelView .invalidate ();
164+ } else {
165+ mWheelView .getParent ().requestDisallowInterceptTouchEvent (false );
166+ }
157167 }
158168 lastTouchY = touchY ;
159169 break ;
0 commit comments