@@ -848,15 +848,11 @@ public void computeScroll() {
848
848
if (mVerticalPermit ) {
849
849
float velocity ;
850
850
if (Build .VERSION .SDK_INT >= 14 ) {
851
- velocity = mScroller .getCurrVelocity ();
851
+ velocity = finalY > 0 ? - mScroller . getCurrVelocity () : mScroller .getCurrVelocity ();
852
852
} else {
853
- velocity = 1f * (finalY - mScroller .getCurrY ()) / Math .max ((mScroller .getDuration () - mScroller .timePassed ()), 1 );
854
- }
855
- if (finalY > 0 ) {// 手势向上划 Footer
856
- animSpinnerBounce (-velocity );
857
- } else if (finalY < 0 ){// 手势向下划 Header
858
- animSpinnerBounce (velocity );
853
+ velocity = 1f * (mScroller .getCurrY () - finalY ) / Math .max ((mScroller .getDuration () - mScroller .timePassed ()), 1 );
859
854
}
855
+ animSpinnerBounce (velocity );
860
856
}
861
857
mScroller .forceFinished (true );
862
858
} else {
@@ -1734,10 +1730,16 @@ public LayoutParams(ViewGroup.LayoutParams source) {
1734
1730
//<editor-fold desc="嵌套滚动 NestedScrolling">
1735
1731
1736
1732
//<editor-fold desc="NestedScrollingParent">
1733
+
1734
+ @ Override
1735
+ public int getNestedScrollAxes () {
1736
+ return mNestedScrollingParentHelper .getNestedScrollAxes ();
1737
+ }
1738
+
1737
1739
@ Override
1738
1740
public boolean onStartNestedScroll (@ NonNull View child , @ NonNull View target , int nestedScrollAxes ) {
1739
1741
boolean accepted = isEnabled () && isNestedScrollingEnabled () && (nestedScrollAxes & ViewCompat .SCROLL_AXIS_VERTICAL ) != 0 ;
1740
- accepted = accepted && (isEnableRefresh () || isEnableLoadMore ());
1742
+ accepted = accepted && (mEnableOverScrollDrag || isEnableRefresh () || isEnableLoadMore ());
1741
1743
return accepted ;
1742
1744
}
1743
1745
@@ -1883,23 +1885,6 @@ public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int
1883
1885
1884
1886
}
1885
1887
1886
- @ Override
1887
- public int getNestedScrollAxes () {
1888
- return mNestedScrollingParentHelper .getNestedScrollAxes ();
1889
- }
1890
-
1891
- @ Override
1892
- public void onStopNestedScroll (@ NonNull View target ) {
1893
- mNestedScrollingParentHelper .onStopNestedScroll (target );
1894
- mNestedScrollInProgress = false ;
1895
- // Finish the spinner for nested scrolling if we ever consumed any
1896
- // unconsumed nested scroll
1897
- mTotalUnconsumed = 0 ;
1898
- overSpinner ();
1899
- // Dispatch up our nested parent
1900
- stopNestedScroll ();
1901
- }
1902
-
1903
1888
@ Override
1904
1889
public void onNestedScroll (@ NonNull View target , int dxConsumed , int dyConsumed , int dxUnconsumed , int dyUnconsumed ) {
1905
1890
// Dispatch up to the nested parent first
@@ -1911,19 +1896,25 @@ public void onNestedScroll(@NonNull View target, int dxConsumed, int dyConsumed,
1911
1896
// 'offset in window 'functionality to see if we have been moved from the event.
1912
1897
// This is a decent indication of whether we should take over the event stream or not.
1913
1898
final int dy = dyUnconsumed + mParentOffsetInWindow [1 ];
1914
- if (dy < 0 && isEnableRefresh () /* && (mRefreshContent == null || mRefreshContent.canRefresh())*/ ) {
1915
- if (mViceState == RefreshState .None ) {
1916
- mKernel .setState (RefreshState .PullDownToRefresh );
1917
- }
1918
- mTotalUnconsumed += Math .abs (dy );
1919
- moveSpinnerInfinitely (mTotalUnconsumed /* + mTouchSpinner*/ );
1920
- } else if (dy > 0 && isEnableLoadMore () /* && (mRefreshContent == null || mRefreshContent.canLoadMore())*/ ) {
1899
+ if (dy != 0 && (mEnableOverScrollDrag || (dy < 0 && isEnableRefresh ()) || (dy > 0 && isEnableLoadMore ()))) {
1921
1900
if (mViceState == RefreshState .None ) {
1922
- mKernel .setState (RefreshState .PullUpToLoad );
1901
+ mKernel .setState (dy > 0 ? RefreshState .PullUpToLoad : RefreshState . PullDownToRefresh );
1923
1902
}
1924
- mTotalUnconsumed -= Math .abs (dy );
1925
- moveSpinnerInfinitely (mTotalUnconsumed /* + mTouchSpinner*/ );
1903
+ moveSpinnerInfinitely (mTotalUnconsumed -= dy );
1926
1904
}
1905
+ // if (dy < 0 && isEnableRefresh() /* && (mRefreshContent == null || mRefreshContent.canRefresh())*/) {
1906
+ // if (mViceState == RefreshState.None) {
1907
+ // mKernel.setState(RefreshState.PullDownToRefresh);
1908
+ // }
1909
+ // mTotalUnconsumed += Math.abs(dy);
1910
+ // moveSpinnerInfinitely(mTotalUnconsumed/* + mTouchSpinner*/);
1911
+ // } else if (dy > 0 && isEnableLoadMore() /* && (mRefreshContent == null || mRefreshContent.canLoadMore())*/) {
1912
+ // if (mViceState == RefreshState.None) {
1913
+ // mKernel.setState(RefreshState.PullUpToLoad);
1914
+ // }
1915
+ // mTotalUnconsumed -= Math.abs(dy);
1916
+ // moveSpinnerInfinitely(mTotalUnconsumed/* + mTouchSpinner*/);
1917
+ // }
1927
1918
}
1928
1919
1929
1920
@ Override
@@ -1935,6 +1926,18 @@ public boolean onNestedPreFling(@NonNull View target, float velocityX, float vel
1935
1926
public boolean onNestedFling (@ NonNull View target , float velocityX , float velocityY , boolean consumed ) {
1936
1927
return dispatchNestedFling (velocityX , velocityY , consumed );
1937
1928
}
1929
+
1930
+ @ Override
1931
+ public void onStopNestedScroll (@ NonNull View target ) {
1932
+ mNestedScrollingParentHelper .onStopNestedScroll (target );
1933
+ mNestedScrollInProgress = false ;
1934
+ // Finish the spinner for nested scrolling if we ever consumed any
1935
+ // unconsumed nested scroll
1936
+ mTotalUnconsumed = 0 ;
1937
+ overSpinner ();
1938
+ // Dispatch up our nested parent
1939
+ stopNestedScroll ();
1940
+ }
1938
1941
//</editor-fold>
1939
1942
1940
1943
//<editor-fold desc="NestedScrollingChild">
0 commit comments