|
6 | 6 | import android.util.AttributeSet;
|
7 | 7 | import android.util.Log;
|
8 | 8 | import android.view.MotionEvent;
|
| 9 | +import android.view.ViewConfiguration; |
9 | 10 | import android.webkit.WebView;
|
10 | 11 | import android.widget.LinearLayout;
|
11 | 12 |
|
@@ -90,10 +91,6 @@ public void onSChanged(int l, int t, int oldl, int oldt) {
|
90 | 91 |
|
91 | 92 | }else {
|
92 | 93 | System.out.println("WebView滑动到了不是底端");
|
93 |
| - if (isScrollUp && mDispatchWebView.isScroll()) { |
94 |
| - mDispatchWebView.ignoreTouchCancel(true); |
95 |
| - isIntercept = true; |
96 |
| - } |
97 | 94 | }
|
98 | 95 | }
|
99 | 96 | });
|
@@ -144,11 +141,12 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
|
144 | 141 | case MotionEvent.ACTION_MOVE:
|
145 | 142 |
|
146 | 143 | y2 = ev.getY();
|
147 |
| - if (y1 - y2 > 50) { |
148 |
| - isScrollUp = true; |
| 144 | + if (y1 - y2 >ViewConfiguration.get(getContext()).getScaledTouchSlop()) { |
| 145 | + isScrollUp = true; |
149 | 146 |
|
150 | 147 | }
|
151 |
| - if (y2 - y1 > 50) { |
| 148 | + if (y2 - y1 > ViewConfiguration.get(getContext()).getScaledTouchSlop()) { |
| 149 | + |
152 | 150 | isScrollUp = false;
|
153 | 151 |
|
154 | 152 | }
|
@@ -201,4 +199,24 @@ public interface RecyclerviewScrollBottom {
|
201 | 199 | void onScrollBottom();
|
202 | 200 |
|
203 | 201 | }
|
| 202 | + public void scrollTop(){ |
| 203 | + if (recyclerView!=null&&mDispatchWebView!=null){ |
| 204 | + recyclerView.scrollToPosition(0); |
| 205 | + mDispatchWebView.scrollTo(0, 0); |
| 206 | + if (mDispatchWebView.isScroll()){ |
| 207 | + mDispatchWebView.ignoreTouchCancel(true); |
| 208 | + isIntercept = true; |
| 209 | + } |
| 210 | + } |
| 211 | + |
| 212 | + } |
| 213 | + |
| 214 | + @Override |
| 215 | + protected void onDetachedFromWindow() { |
| 216 | + Log.d("销毁","销毁"); |
| 217 | + super.onDetachedFromWindow(); |
| 218 | + mDispatchWebView.destroy(); |
| 219 | + mDispatchWebView=null; |
| 220 | + recyclerView=null; |
| 221 | + } |
204 | 222 | }
|
0 commit comments