From 448071b02d40904de3264bab0dc69ca48ef318e5 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 18 Feb 2014 22:11:10 -0500 Subject: [PATCH] Fix NPE when POLLING bridge mode is used. --- framework/.settings/org.eclipse.jdt.core.prefs | 4 ++++ .../src/org/apache/cordova/NativeToJsMessageQueue.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 framework/.settings/org.eclipse.jdt.core.prefs diff --git a/framework/.settings/org.eclipse.jdt.core.prefs b/framework/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/framework/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java index ce8e9b2a..dddc022b 100755 --- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java +++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java @@ -83,7 +83,7 @@ public class NativeToJsMessageQueue { this.cordova = cordova; this.webView = webView; registeredListeners = new BridgeMode[4]; - registeredListeners[0] = null; // Polling. Requires no logic. + registeredListeners[0] = new PollingBridgeMode(); registeredListeners[1] = new LoadUrlBridgeMode(); registeredListeners[2] = new OnlineEventsBridgeMode(); registeredListeners[3] = new PrivateApiBridgeMode(); @@ -279,7 +279,13 @@ public class NativeToJsMessageQueue { abstract void onNativeToJsMessageAvailable(); void notifyOfFlush(boolean fromOnlineEvent) {} } - + + /** Uses JS polls for messages on a timer.. */ + private class PollingBridgeMode extends BridgeMode { + @Override void onNativeToJsMessageAvailable() { + } + } + /** Uses webView.loadUrl("javascript:") to execute messages. */ private class LoadUrlBridgeMode extends BridgeMode { final Runnable runnable = new Runnable() {