Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(android) Defensive code to prevent NULL reference exceptions for async #503

Merged
merged 2 commits into from
Jan 4, 2020
Merged
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
18 changes: 12 additions & 6 deletions src/android/InAppBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ else if (action.equals("show")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
if (dialog != null) {
dialog.show();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
Expand All @@ -324,7 +326,9 @@ else if (action.equals("hide")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.hide();
if (dialog != null) {
dialog.hide();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
Expand Down Expand Up @@ -1065,12 +1069,14 @@ public void postMessage(String data) {
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;

dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
if (dialog != null) {
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
}
// the goal of openhidden is to load the url and not display it
// Show() needs to be called to cause the URL to be loaded
if(openWindowHidden) {
if (openWindowHidden && dialog != null) {
dialog.hide();
}
}
Expand Down