CB-12560: (android) fix null pointer with callback when loading multiple urls

This commit is contained in:
Douglas Blood 2017-03-10 13:30:08 +13:00
parent 0f5de8524f
commit fc08376ee1

View File

@ -259,7 +259,7 @@ public class InAppBrowser extends CordovaPlugin {
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult);
callbackContext.sendPluginResult(pluginResult);
}
else if (action.equals("hide")) {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@ -270,7 +270,7 @@ public class InAppBrowser extends CordovaPlugin {
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
pluginResult.setKeepCallback(true);
this.callbackContext.sendPluginResult(pluginResult);
callbackContext.sendPluginResult(pluginResult);
}
else {
return false;
@ -869,12 +869,13 @@ public class InAppBrowser extends CordovaPlugin {
* @param status the status code to return to the JavaScript environment
*/
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
if (callbackContext != null) {
final CallbackContext localCallbackContext = callbackContext;
if (localCallbackContext != null) {
PluginResult result = new PluginResult(status, obj);
result.setKeepCallback(keepCallback);
callbackContext.sendPluginResult(result);
localCallbackContext.sendPluginResult(result);
if (!keepCallback) {
callbackContext = null;
this.callbackContext = null;
}
}
}