@ Override protected void onScrollChanged ( int l , int t , int oldl , int oldt ) { super . onScrollChanged ( l , t , oldl , oldt ) ; if ( mTrackedChild == null ) { if ( getChildCount ( ) > 0 ) { mTrackedChild = getChildInTheMiddle ( ) ; mTrackedChildPrevTop = mTrackedChild . getTop ( ) ; mTrackedChildPrevPosition = getPositionForView ( mTrackedChild ) ; } } else { boolean childIsSafeToTrack = mTrackedChild . getParent ( ) == this && getPositionForView ( mTrackedChild ) == mTrackedChildPrevPosition ; if ( childIsSafeToTrack ) { int top = mTrackedChild . getTop ( ) ; float deltaY = top - mTrackedChildPrevTop ; if ( deltaY == 0 ) { //When we scroll so fast the list this value becomes 0 all the time // so we don't want the other list stop, and we give it the last //no 0 value we have deltaY = OldDeltaY ; } else { OldDeltaY = deltaY ; } updateChildrenControlPoints ( deltaY ) ; mTrackedChildPrevTop = top ; } else { mTrackedChild = null ; } } }
Calculate the scroll distance comparing the distance with the top of the list of the current child and the last one tracked