Skip to content

Commit 78ed7cf

Browse files
committed
#
1 parent 87bdce5 commit 78ed7cf

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

library/src/main/java/com/just/library/DefaultChromeClient.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public boolean onJsAlert(WebView view, String url, String message, JsResult resu
116116
}
117117

118118
Activity mActivity = this.mActivityWeakReference.get();
119-
if (mActivity == null) {
119+
if (mActivity == null||mActivity.isFinishing()) {
120120
result.cancel();
121121
return true;
122122
}
@@ -274,7 +274,7 @@ private void toDismissDialog(Dialog dialog) {
274274
private void showJsConfirm(String message, final JsResult result) {
275275

276276
Activity mActivity = this.mActivityWeakReference.get();
277-
if (mActivity == null) {
277+
if (mActivity == null||mActivity.isFinishing()) {
278278
result.cancel();
279279
return;
280280
}
@@ -311,7 +311,7 @@ private void toCancelJsresult(JsResult result) {
311311
private void showJsPrompt(String message, final JsPromptResult js, String defaultstr) {
312312

313313
Activity mActivity = this.mActivityWeakReference.get();
314-
if (mActivity == null) {
314+
if (mActivity == null||mActivity.isFinishing()) {
315315
js.cancel();
316316
return;
317317
}
@@ -387,8 +387,10 @@ private void openFileChooserAboveL(WebView webView, ValueCallback<Uri[]> filePat
387387

388388

389389
Activity mActivity = this.mActivityWeakReference.get();
390-
if (mActivity == null)
390+
if (mActivity == null||mActivity.isFinishing()){
391+
filePathCallback.onReceiveValue(new Uri[]{});
391392
return;
393+
}
392394
IFileUploadChooser mIFileUploadChooser = this.mIFileUploadChooser;
393395
this.mIFileUploadChooser = mIFileUploadChooser = new FileUpLoadChooserImpl.Builder()
394396
.setWebView(webView)
@@ -437,8 +439,10 @@ public void openFileChooser(ValueCallback valueCallback, String acceptType) {
437439

438440
private void createAndOpenCommonFileLoader(ValueCallback valueCallback) {
439441
Activity mActivity = this.mActivityWeakReference.get();
440-
if (mActivity == null)
442+
if (mActivity == null||mActivity.isFinishing()){
443+
valueCallback.onReceiveValue(new Object());
441444
return;
445+
}
442446
this.mIFileUploadChooser = new FileUpLoadChooserImpl.Builder()
443447
.setWebView(this.mWebView)
444448
.setActivity(mActivity)

library/src/main/java/com/just/library/DefaultWebLifeCycleImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class DefaultWebLifeCycleImpl implements WebLifeCycle {
1818
public void onResume() {
1919
if (this.mWebView != null) {
2020

21-
if (Build.VERSION.SDK_INT >= 11)
21+
if (Build.VERSION.SDK_INT >= 11){
2222
this.mWebView.onResume();
23-
23+
}
2424
this.mWebView.resumeTimers();
2525
}
2626

@@ -31,9 +31,11 @@ public void onResume() {
3131
public void onPause() {
3232

3333
if (this.mWebView != null) {
34-
this.mWebView.pauseTimers();
35-
if (Build.VERSION.SDK_INT >= 11)
34+
35+
if (Build.VERSION.SDK_INT >= 11){
3636
this.mWebView.onPause();
37+
}
38+
this.mWebView.pauseTimers();
3739
}
3840
}
3941

0 commit comments

Comments
 (0)