mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
CB-6837 Fix leaked window when hitting back button while alert being rendered
Keep track of the last AlertDialog showed. The last dialog showed that is rendered while hitting back button it causes a leaked window. Instead of perform a full track of all dialogs created, only destroy the last one showed, this fixes the problem. close #122
This commit is contained in:
parent
6cbf6b7875
commit
890e12c306
@ -65,6 +65,9 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
// the video progress view
|
||||
private View mVideoProgressView;
|
||||
|
||||
//Keep track of last AlertDialog showed
|
||||
private AlertDialog lastHandledDialog;
|
||||
|
||||
// File Chooser
|
||||
public ValueCallback<Uri> mUploadMessage;
|
||||
|
||||
@ -123,7 +126,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -172,7 +175,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -216,7 +219,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
res.cancel();
|
||||
}
|
||||
});
|
||||
dlg.show();
|
||||
lastHandledDialog = dlg.show();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -328,4 +331,11 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
public ValueCallback<Uri> getValueCallback() {
|
||||
return this.mUploadMessage;
|
||||
}
|
||||
|
||||
public void destroyLastDialog(){
|
||||
if(lastHandledDialog != null){
|
||||
lastHandledDialog.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -788,6 +788,9 @@ public class CordovaWebView extends WebView {
|
||||
|
||||
// Load blank page so that JavaScript onunload is called
|
||||
this.loadUrl("about:blank");
|
||||
|
||||
//Remove last AlertDialog
|
||||
this.chromeClient.destroyLastDialog();
|
||||
|
||||
// Forward to plugins
|
||||
if (this.pluginManager != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user