Skip to content

Commit

Permalink
Merge pull request #503 from alexyazvinsky/def-fix
Browse files Browse the repository at this point in the history
(android) Defensive code to prevent NULL reference exceptions for async
  • Loading branch information
NiklasMerz authored Jan 4, 2020
2 parents 82bbe29 + d4338bd commit 7b42f3e
Showing 1 changed file with 12 additions and 6 deletions.
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

0 comments on commit 7b42f3e

Please sign in to comment.