mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Implements the LOAD_URL Native->JS bridge mode
(without keyboard work-around)
This commit is contained in:
parent
b40eb0a454
commit
7fa4515c28
@ -47,9 +47,10 @@ public class NativeToJsMessageQueue {
|
||||
private BridgeMode[] registeredListeners;
|
||||
|
||||
public NativeToJsMessageQueue(CordovaWebView webView) {
|
||||
registeredListeners = new BridgeMode[2];
|
||||
registeredListeners = new BridgeMode[3];
|
||||
registeredListeners[0] = null;
|
||||
registeredListeners[1] = new CallbackBridgeMode(webView);
|
||||
registeredListeners[2] = new LoadUrlBridgeMode(webView);
|
||||
reset();
|
||||
// POLLING: 0,
|
||||
// HANGING_GET: 1,
|
||||
@ -148,6 +149,7 @@ public class NativeToJsMessageQueue {
|
||||
void onNativeToJsMessageAvailable(NativeToJsMessageQueue queue);
|
||||
}
|
||||
|
||||
/** Uses a local server to send messages to JS via an XHR */
|
||||
private static class CallbackBridgeMode implements BridgeMode {
|
||||
private CordovaWebView webView;
|
||||
public CallbackBridgeMode(CordovaWebView webView) {
|
||||
@ -159,5 +161,16 @@ public class NativeToJsMessageQueue {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Uses webView.loadUrl("javascript:") to execute messages. */
|
||||
public static class LoadUrlBridgeMode implements BridgeMode {
|
||||
private CordovaWebView webView;
|
||||
public LoadUrlBridgeMode(CordovaWebView webView) {
|
||||
this.webView = webView;
|
||||
}
|
||||
public void onNativeToJsMessageAvailable(NativeToJsMessageQueue queue) {
|
||||
webView.loadUrlNow("javascript:" + queue.popAll());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user