@@ -908,7 +908,7 @@ public boolean dispatchTouchEvent(MotionEvent e) { |
908 | 908 | mLastSpinner = 0; |
909 | 909 | mTouchSpinner = mSpinner; |
910 | 910 | mIsBeingDragged = false; |
911 | | -// mEnableDisallowIntercept = false; |
| 911 | + mEnableDisallowIntercept = false; |
912 | 912 | /*----------------------------------------------------*/ |
913 | 913 | mSuperDispatchTouchEvent = super.dispatchTouchEvent(e); |
914 | 914 | if (mState == RefreshState.TwoLevel && mTouchY < 5 * thisView.getMeasuredHeight() / 6) { |
@@ -924,7 +924,7 @@ public boolean dispatchTouchEvent(MotionEvent e) { |
924 | 924 | float dx = touchX - mTouchX; |
925 | 925 | float dy = touchY - mTouchY; |
926 | 926 | mVelocityTracker.addMovement(e);//速度追踪 |
927 | | - if (!mIsBeingDragged /*&& !mEnableDisallowIntercept*/ && mDragDirection != 'h' && mRefreshContent != null) {//没有拖动之前,检测 canRefresh canLoadMore 来开启拖动 |
| 927 | + if (!mIsBeingDragged && !mEnableDisallowIntercept && mDragDirection != 'h' && mRefreshContent != null) {//没有拖动之前,检测 canRefresh canLoadMore 来开启拖动 |
928 | 928 | if (mDragDirection == 'v' || (Math.abs(dy) >= mTouchSlop && Math.abs(dx) < Math.abs(dy))) {//滑动允许最大角度为45度 |
929 | 929 | mDragDirection = 'v'; |
930 | 930 | if (dy > 0 && (mSpinner < 0 || ((mEnableOverScrollDrag || mEnableRefresh) && mRefreshContent.canRefresh()))) { |
@@ -1020,13 +1020,23 @@ public boolean dispatchTouchEvent(MotionEvent e) { |
1020 | 1020 | return super.dispatchTouchEvent(e); |
1021 | 1021 | } |
1022 | 1022 |
|
1023 | | -// @Override |
1024 | | -// public void requestDisallowInterceptTouchEvent(boolean b) { |
1025 | | -// View target = mRefreshContent.getScrollableView(); |
1026 | | -// if ((Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView)) && (/*target == null || */ViewCompat.isNestedScrollingEnabled(target))) { |
1027 | | -// super.requestDisallowInterceptTouchEvent(b); |
1028 | | -// } |
1029 | | -// } |
| 1023 | + /** |
| 1024 | + * 这段代码来自谷歌官方的 SwipeRefreshLayout |
| 1025 | + * 主要是为了让老版本的 ListView 能平滑的下拉 而选择性的屏蔽 requestDisallowInterceptTouchEvent |
| 1026 | + * 应用场景已经在英文注释中解释清楚,大部分第三方下拉刷新库都保留了这段代码,本库也不例外 |
| 1027 | + */ |
| 1028 | + @Override |
| 1029 | + public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { |
| 1030 | + // if this is a List < L or another view that doesn't support nested |
| 1031 | + // scrolling, ignore this request so that the vertical scroll event |
| 1032 | + // isn't stolen |
| 1033 | + View target = mRefreshContent.getScrollableView(); |
| 1034 | + if ((android.os.Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView)) |
| 1035 | + && (/*target == null || */ViewCompat.isNestedScrollingEnabled(target))) { |
| 1036 | + mEnableDisallowIntercept = disallowIntercept; |
| 1037 | + super.requestDisallowInterceptTouchEvent(disallowIntercept); |
| 1038 | + } |
| 1039 | + } |
1030 | 1040 |
|
1031 | 1041 | /** |
1032 | 1042 | * 在必要的时候 开始 Fling 模式 |
@@ -1103,24 +1113,6 @@ protected boolean interceptAnimatorByAction(int action) { |
1103 | 1113 | } |
1104 | 1114 | return reboundAnimator != null; |
1105 | 1115 | } |
1106 | | - |
1107 | | - /* |
1108 | | - * 这段代码来自谷歌官方的 SwipeRefreshLayout |
1109 | | - * 应用场景已经在英文注释中解释清楚 |
1110 | | - * 大部分第三方下拉刷新库都保留了这段代码,本库也不例外 |
1111 | | - */ |
1112 | | - @Override |
1113 | | - public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { |
1114 | | - // if this is a List < L or another view that doesn't support nested |
1115 | | - // scrolling, ignore this request so that the vertical scroll event |
1116 | | - // isn't stolen |
1117 | | - View target = mRefreshContent.getScrollableView(); |
1118 | | - if ((android.os.Build.VERSION.SDK_INT >= 21 || !(target instanceof AbsListView)) |
1119 | | - && (/*target == null || */ViewCompat.isNestedScrollingEnabled(target))) { |
1120 | | - mEnableDisallowIntercept = disallowIntercept; |
1121 | | - super.requestDisallowInterceptTouchEvent(disallowIntercept); |
1122 | | - } |
1123 | | - } |
1124 | 1116 | //</editor-fold> |
1125 | 1117 |
|
1126 | 1118 | //<editor-fold desc="状态更改 state changes"> |
|