Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions dsbridge/src/main/java/wendu/dsbridge/DWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ public boolean onJsAlert(WebView view, String url, final String message, final J
return true;
}
}

if (isActivityFinishing()) return true;

Dialog alertDialog = new AlertDialog.Builder(getContext()).
setMessage(message).
setCancelable(false).
Expand Down Expand Up @@ -717,6 +720,9 @@ public void onClick(DialogInterface dialog, int which) {
}
}
};

if (isActivityFinishing()) return true;

new AlertDialog.Builder(getContext())
.setMessage(message)
.setCancelable(false)
Expand Down Expand Up @@ -765,6 +771,9 @@ public void onClick(DialogInterface dialog, int which) {
}
}
};

if (isActivityFinishing()) return true;

new AlertDialog.Builder(getContext())
.setTitle(message)
.setView(editText)
Expand Down Expand Up @@ -907,6 +916,22 @@ public void openFileChooser(ValueCallback valueCallback, String acceptType) {

};

private boolean isActivityFinishing() {
Context context = getContext();
if (context instanceof Activity) {
Activity activity = (Activity) context;
if (activity.isFinishing()) {
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (activity.isDestroyed()) {
return true;
}
}
}
return false;
}

@Override
public void clearCache(boolean includeDiskFiles) {
super.clearCache(includeDiskFiles);
Expand Down