CB-6936: Merge pull request #304 from uareurapid/master

CB-6936: fix crash when calling methods on a destroyed webview
This commit is contained in:
Joe Bowser 2017-09-15 13:26:21 -07:00 committed by GitHub
commit dddb2837dd

View File

@ -110,8 +110,12 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() {
@Override @Override
public void setNetworkAvailable(boolean value) { public void setNetworkAvailable(boolean value) {
//sometimes this can be called after calling webview.destroy() on destroy()
//thus resulting in a NullPointerException
if(webView!=null) {
webView.setNetworkAvailable(value); webView.setNetworkAvailable(value);
} }
}
@Override @Override
public void runOnUiThread(Runnable r) { public void runOnUiThread(Runnable r) {
SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r);