fix: swipe refresh layout abnormal refreshing with nested webview
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@
|
|||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
|
/release
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
*.apk
|
*.apk
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ android {
|
|||||||
applicationId "com.stardust.scriptdroid"
|
applicationId "com.stardust.scriptdroid"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 213
|
versionCode 214
|
||||||
versionName "3.0.0 Alpha14"
|
versionName "3.0.0 Alpha15"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
ndk {
|
ndk {
|
||||||
|
|||||||
@@ -40,13 +40,14 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|||||||
* Created by Stardust on 2017/8/22.
|
* Created by Stardust on 2017/8/22.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EWebView extends SwipeRefreshLayout implements SwipeRefreshLayout.OnRefreshListener, OnActivityResultDelegate {
|
public class EWebView extends FrameLayout implements SwipeRefreshLayout.OnRefreshListener, OnActivityResultDelegate {
|
||||||
|
|
||||||
private static final List<String> IMAGE_TYPES = Arrays.asList("png", "jpg", "bmp");
|
private static final List<String> IMAGE_TYPES = Arrays.asList("png", "jpg", "bmp");
|
||||||
private static final int CHOOSE_IMAGE = 42222;
|
private static final int CHOOSE_IMAGE = 42222;
|
||||||
|
|
||||||
private WebView mWebView;
|
private WebView mWebView;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
|
private SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
|
||||||
public EWebView(Context context) {
|
public EWebView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -62,8 +63,9 @@ public class EWebView extends SwipeRefreshLayout implements SwipeRefreshLayout.O
|
|||||||
private void init() {
|
private void init() {
|
||||||
inflate(getContext(), R.layout.ewebview, this);
|
inflate(getContext(), R.layout.ewebview, this);
|
||||||
mWebView = (WebView) findViewById(R.id.web_view);
|
mWebView = (WebView) findViewById(R.id.web_view);
|
||||||
|
mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
|
||||||
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
|
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
|
||||||
setOnRefreshListener(this);
|
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||||
setUpWebView();
|
setUpWebView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ public class EWebView extends SwipeRefreshLayout implements SwipeRefreshLayout.O
|
|||||||
mWebView.reload();
|
mWebView.reload();
|
||||||
Observable.timer(2, TimeUnit.SECONDS)
|
Observable.timer(2, TimeUnit.SECONDS)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(t -> setRefreshing(false));
|
.subscribe(t -> mSwipeRefreshLayout.setRefreshing(false));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +191,7 @@ public class EWebView extends SwipeRefreshLayout implements SwipeRefreshLayout.O
|
|||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
mProgressBar.setVisibility(GONE);
|
mProgressBar.setVisibility(GONE);
|
||||||
setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/swipe_refresh_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
|
<android.support.v4.widget.SwipeRefreshLayout
|
||||||
|
android:id="@+id/swipe_refresh_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@@ -13,13 +14,13 @@
|
|||||||
android:id="@+id/web_view"
|
android:id="@+id/web_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
</android.support.v4.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="2dp"
|
android:layout_height="2dp"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
Reference in New Issue
Block a user