Skip to content

Commit 3567103

Browse files
author
yangyufei
committed
fix-webview-touch-error
1 parent f21490b commit 3567103

16 files changed

Lines changed: 320 additions & 56 deletions

app/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 26
4+
compileSdkVersion 27
55
defaultConfig {
66
applicationId "jarvis.com.nestedtouchscrollinglayout"
77
minSdkVersion 23
8-
targetSdkVersion 26
8+
targetSdkVersion 27
99
versionCode 1
1010
versionName "1.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,14 +20,16 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:26.0.0'
24-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
2523
testImplementation 'junit:junit:4.12'
24+
//noinspection GradleCompatible
2625
androidTestImplementation 'com.android.support.test:runner:1.0.2'
2726
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
2827

29-
implementation 'com.android.support:recyclerview-v7:26.0.0'
30-
implementation 'com.android.support:design:26.0.0'
28+
implementation 'com.android.support:recyclerview-v7:27.1.1'
29+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30+
implementation 'com.android.support:design:27.1.1'
31+
implementation 'com.android.support:appcompat-v7:27.1.1'
32+
3133

3234

3335
api project(':library')

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="jarvis.com.nestedtouchscrollinglayout">
45

56
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
67
<uses-permission android:name="android.permission.INTERNET"/>
78

89
<application
9-
android:allowBackup="true"
1010
android:icon="@mipmap/ic_launcher"
1111
android:label="@string/app_name"
1212
android:roundIcon="@mipmap/ic_launcher_round"

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/AppbarLayoutActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
6969
mNestedTouchScrollingLayout = findViewById(R.id.wrapper);
7070
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
7171
@Override
72-
public void onNestChildScrollChange(float deltaY) {
72+
public void onNestChildScrollChange(float deltaY, float velocityY) {
7373

7474
}
7575

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/BottomSheetActivity.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import android.widget.TextView;
1818

1919
import jarvis.com.library.NestedTouchScrollingLayout;
20+
import jarvis.com.nestedtouchscrollinglayout.view.IndicatorLineView;
2021

2122
/**
2223
* @author Jarvis.
@@ -36,6 +37,8 @@ public class BottomSheetActivity extends BaseActivity {
3637

3738
private NestedTouchScrollingLayout mNestedTouchScrollingLayout;
3839

40+
private IndicatorLineView mIndicatorLineView;
41+
3942
@Override
4043
protected void onCreate(@Nullable Bundle savedInstanceState) {
4144
super.onCreate(savedInstanceState);
@@ -48,6 +51,8 @@ public void onClick(View view) {
4851
}
4952
});
5053

54+
mIndicatorLineView = findViewById(R.id.indicator);
55+
5156
mContainerRecycler = findViewById(R.id.container_rv);
5257
mContainerRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
5358
mContainerRecycler.setAdapter(new InnerAdapter(this, 0x9966CC));
@@ -72,8 +77,8 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
7277
mNestedTouchScrollingLayout = findViewById(R.id.wrapper);
7378
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
7479
@Override
75-
public void onNestChildScrollChange(float deltaY) {
76-
80+
public void onNestChildScrollChange(float deltaY, float velocityY) {
81+
mIndicatorLineView.updateVelocity(velocityY);
7782
}
7883

7984
@Override
@@ -111,7 +116,6 @@ public void onNestChildScrollRelease(final float deltaY, final int velocityY) {
111116

112117
@Override
113118
public void onFingerUp(float velocityY) {
114-
115119
}
116120

117121
@Override

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/RecyclerViewActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
6464

6565
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
6666
@Override
67-
public void onNestChildScrollChange(float deltaY) {
67+
public void onNestChildScrollChange(float deltaY, float velocityY) {
6868

6969
}
7070

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/ViewAndRecyclerViewActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
7979

8080
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
8181
@Override
82-
public void onNestChildScrollChange(float deltaY) {
82+
public void onNestChildScrollChange(float deltaY, float velocityY) {
8383
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mWrapper.getLayoutParams();
8484
params.height = (int) (DisplayUtils.dpToPixel(ViewAndRecyclerViewActivity.this, 400) + deltaY);
8585
mWrapper.setLayoutParams(params);
@@ -97,7 +97,7 @@ public void run() {
9797

9898
@Override
9999
public void onFingerUp(float velocityY) {
100-
100+
Log.e("jarivs-velocityY ----> ", "" + velocityY);
101101
}
102102

103103
@Override

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
3434
initWebSettings();
3535
initWebViewClient();
3636

37-
mWebView.loadUrl("https://www.baidu.com/");
37+
mWebView.loadUrl("http://m.meten.com/xxl/adult.html");
3838

3939
mContainer = findViewById(R.id.wrapper);
4040

4141
mContainer.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
4242
@Override
43-
public void onNestChildScrollChange(float deltaY) {
43+
public void onNestChildScrollChange(float deltaY, float velocityY) {
4444

4545
}
4646

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/WebViewAndRecyclerViewActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5353
mWebView = findViewById(R.id.container_wb);
5454
initWebSettings();
5555
initWebViewClient();
56-
mWebView.loadUrl("https://www.baidu.com/");
56+
mWebView.loadUrl("http://m.meten.com/xxl/adult.html");
5757

5858
mContainerRecycler = findViewById(R.id.container_rv);
5959
mContainerRecycler.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
@@ -86,7 +86,7 @@ public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull R
8686

8787
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
8888
@Override
89-
public void onNestChildScrollChange(float deltaY) {
89+
public void onNestChildScrollChange(float deltaY, float velocityY) {
9090
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mWebView.getLayoutParams();
9191
params.height = (int) (DisplayUtils.dpToPixel(WebViewAndRecyclerViewActivity.this, 250) + deltaY);
9292
mWebView.setLayoutParams(params);

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/BaseChildFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
2828
mParent = (NestedTouchScrollingLayout) getChildView().getParent();
2929
mParent.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
3030
@Override
31-
public void onNestChildScrollChange(float deltaY) {
31+
public void onNestChildScrollChange(float deltaY, float velocityY) {
3232

3333
}
3434

app/src/main/java/jarvis/com/nestedtouchscrollinglayout/fragment/RecyclerViewFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
5858

5959
mNestedTouchScrollingLayout.registerNestScrollChildCallback(new NestedTouchScrollingLayout.INestChildScrollChange() {
6060
@Override
61-
public void onNestChildScrollChange(float deltaY) {
61+
public void onNestChildScrollChange(float deltaY, float velocityY) {
6262

6363
}
6464

0 commit comments

Comments
 (0)