Merge pull request #503 from alexyazvinsky/def-fix

(android) Defensive code to prevent NULL reference exceptions for async
This commit is contained in:
Niklas Merz 2020-01-04 08:57:52 +01:00 committed by GitHub
commit 7b42f3e105
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -313,7 +313,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() { this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
dialog.show(); if (dialog != null) {
dialog.show();
}
} }
}); });
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@ -324,7 +326,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() { this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
dialog.hide(); if (dialog != null) {
dialog.hide();
}
} }
}); });
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@ -1065,12 +1069,14 @@ public class InAppBrowser extends CordovaPlugin {
lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT;
dialog.setContentView(main); if (dialog != null) {
dialog.show(); dialog.setContentView(main);
dialog.getWindow().setAttributes(lp); dialog.show();
dialog.getWindow().setAttributes(lp);
}
// the goal of openhidden is to load the url and not display it // 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 // Show() needs to be called to cause the URL to be loaded
if(openWindowHidden) { if (openWindowHidden && dialog != null) {
dialog.hide(); dialog.hide();
} }
} }