org.apache.cordova.NativeToJsMessageQueue Java Examples
The following examples show how to use
org.apache.cordova.NativeToJsMessageQueue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CordovaGeckoViewEngine.java From cordova-mozillaview-engine with Apache License 2.0 | 6 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; chrome = new CordovaGeckoViewChrome(this, cordova); // We set the delegate on the Engine first. webView.setChromeDelegate(chrome); webView.loadConfiguration(); webView.init(this, cordova); }
Example #2
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 6 votes |
@Test public void testJsonPopAndEncodeAsJs() { NativeToJsMessageQueue.BridgeMode bridge; bridge = new NativeToJsMessageQueue.NoOpBridgeMode(); queue.addBridgeMode(bridge); queue.setBridgeMode(0); JSONObject object = new JSONObject(); try { object.put("test", "value"); } catch (JSONException e) { e.printStackTrace(); } PluginResult result = new PluginResult(PluginResult.Status.OK, object); queue.addPluginResult(result, TEST_CALLBACK_ID); assertFalse(queue.isEmpty()); String resultString = queue.popAndEncodeAsJs(); assertTrue(resultString.startsWith("cordova.callbackFromNative")); }
Example #3
Source File: X5WebViewEngine.java From cordova-plugin-x5-tbs with Apache License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { X5WebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #4
Source File: SystemWebViewEngine.java From countly-sdk-cordova with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #5
Source File: SystemWebViewEngine.java From lona with GNU General Public License v3.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #6
Source File: XWalkWebViewEngine.java From cordova-crosswalk-engine with Apache License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; CordovaPlugin activityDelegatePlugin = new CordovaPlugin() { @Override public void onResume(boolean multitasking) { activityDelegate.onResume(); } }; pluginManager.addService(new PluginEntry("XWalkActivityDelegate", activityDelegatePlugin)); webView.init(this); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode( new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { XWalkWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); }
Example #7
Source File: SystemWebViewEngine.java From pychat with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #8
Source File: SystemWebViewEngine.java From chappiecast with Mozilla Public License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #9
Source File: SystemWebViewEngine.java From cordova-plugin-intent with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #10
Source File: SystemWebViewEngine.java From a2cardboard with Apache License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #11
Source File: SystemWebViewEngine.java From cordova-plugin-app-update-demo with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #12
Source File: X5WebViewEngine.java From cordova-plugin-x5engine-webview with Apache License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { X5WebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #13
Source File: SystemWebViewEngine.java From app-icon with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #14
Source File: MockCordovaWebViewImpl.java From OsmGo with MIT License | 5 votes |
@Override public void onNativeToJsMessageAvailable(final NativeToJsMessageQueue queue) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { String js = queue.popAndEncodeAsJs(); if (js != null) { webView.evaluateJavascript(js, null); } } }); }
Example #15
Source File: MockCordovaWebViewImpl.java From OsmGo with MIT License | 5 votes |
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries, CordovaPreferences preferences, WebView webView) { this.cordova = cordova; this.webView = webView; this.preferences = preferences; this.pluginManager = new PluginManager(this, this.cordova, pluginEntries); this.resourceApi = new CordovaResourceApi(this.context, this.pluginManager); nativeToJsMessageQueue = new NativeToJsMessageQueue(); nativeToJsMessageQueue.addBridgeMode(new CapacitorEvalBridgeMode(webView, this.cordova)); nativeToJsMessageQueue.setBridgeMode(0); this.cookieManager = new CapacitorCordovaCookieManager(webView); this.pluginManager.init(); }
Example #16
Source File: SystemWebViewEngine.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #17
Source File: SystemWebViewEngine.java From keemob with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #18
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testNullPopAndEncodeAsJs() { NativeToJsMessageQueue queue = new NativeToJsMessageQueue(); queue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode()); queue.setBridgeMode(0); PluginResult result = new PluginResult(PluginResult.Status.OK, (String)null); queue.addPluginResult(result, TEST_CALLBACK_ID); assertFalse(queue.isEmpty()); String resultString = queue.popAndEncodeAsJs(); assertEquals(resultString, "cordova.callbackFromNative('" + TEST_CALLBACK_ID + "',true,1,[null],false);"); }
Example #19
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testMultipartPopAndEncodeAsJs() { ArrayList<PluginResult> multiparts = new ArrayList<PluginResult>(); for (int i=0; i<5; i++) { multiparts.add(new PluginResult(PluginResult.Status.OK, i)); } PluginResult multipartresult = new PluginResult(PluginResult.Status.OK, multiparts); NativeToJsMessageQueue queue = new NativeToJsMessageQueue(); queue.addBridgeMode(new NativeToJsMessageQueue.NoOpBridgeMode()); queue.setBridgeMode(0); queue.addPluginResult(multipartresult, "37"); String result = queue.popAndEncodeAsJs(); assertEquals(result, "cordova.callbackFromNative('37',true,1,[0,1,2,3,4],false);"); }
Example #20
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testStringPopAndEncodeAsJs() { NativeToJsMessageQueue.BridgeMode bridge; bridge = new NativeToJsMessageQueue.NoOpBridgeMode(); queue.addBridgeMode(bridge); queue.setBridgeMode(0); PluginResult result = new PluginResult(PluginResult.Status.OK, "String Plugin Result"); queue.addPluginResult(result, TEST_CALLBACK_ID); assertFalse(queue.isEmpty()); String resultString = queue.popAndEncodeAsJs(); assertTrue(resultString.startsWith("cordova.callbackFromNative")); }
Example #21
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testBasicPopAndEncodeAsJs() { NativeToJsMessageQueue.BridgeMode bridge; bridge = new NativeToJsMessageQueue.NoOpBridgeMode(); queue.addBridgeMode(bridge); queue.setBridgeMode(0); PluginResult result = new PluginResult(PluginResult.Status.OK); queue.addPluginResult(result, TEST_CALLBACK_ID); assertFalse(queue.isEmpty()); String resultString = queue.popAndEncodeAsJs(); assertTrue(resultString.startsWith("cordova.callbackFromNative")); }
Example #22
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testPopAndEncode() { NativeToJsMessageQueue.BridgeMode bridge; bridge = new NativeToJsMessageQueue.NoOpBridgeMode(); queue.addBridgeMode(bridge); queue.setBridgeMode(0); PluginResult result = new PluginResult(PluginResult.Status.OK); queue.addPluginResult(result, TEST_CALLBACK_ID); assertFalse(queue.isEmpty()); String resultString = queue.popAndEncode(false); String [] results = resultString.split(" "); assertEquals(TEST_CALLBACK_ID, results[2]); }
Example #23
Source File: NativeToJsMessageQueueTest.java From keemob with MIT License | 5 votes |
@Test public void testEnabledBridge() { NativeToJsMessageQueue.BridgeMode bridge; bridge = new NativeToJsMessageQueue.NoOpBridgeMode(); queue.addBridgeMode(bridge); queue.setBridgeMode(0); assertTrue(queue.isBridgeEnabled()); }
Example #24
Source File: SystemWebViewEngine.java From keemob with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #25
Source File: X5WebViewEngine.java From x5webview-cordova-plugin with Apache License 2.0 | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { X5WebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #26
Source File: SystemWebViewEngine.java From ultimate-cordova-webview-app with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #27
Source File: SystemWebViewEngine.java From xmall with MIT License | 5 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, CordovaWebViewEngine.Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override 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); } } @Override public void runOnUiThread(Runnable r) { SystemWebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }
Example #28
Source File: X5WebViewEngine.java From cordova-plugin-x5-webview with Apache License 2.0 | 4 votes |
@Override public void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, CordovaResourceApi resourceApi, PluginManager pluginManager, NativeToJsMessageQueue nativeToJsMessageQueue) { if (this.cordova != null) { throw new IllegalStateException(); } // Needed when prefs are not passed by the constructor if (preferences == null) { preferences = parentWebView.getPreferences(); } this.parentWebView = parentWebView; this.cordova = cordova; this.client = client; this.resourceApi = resourceApi; this.pluginManager = pluginManager; this.nativeToJsMessageQueue = nativeToJsMessageQueue; webView.init(this, cordova); initWebViewSettings(); nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode(new NativeToJsMessageQueue.OnlineEventsBridgeMode.OnlineEventsBridgeModeDelegate() { @Override public void setNetworkAvailable(boolean value) { webView.setNetworkAvailable(value); } @Override public void runOnUiThread(Runnable r) { X5WebViewEngine.this.cordova.getActivity().runOnUiThread(r); } })); /* Pay attention: * Error maybe occur here!!! * If your cordova-android version below 6+,this method about EvalBridgeMode() may be not existed. * Please comment out below the lines 126-127. */ if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) nativeToJsMessageQueue.addBridgeMode(new NativeToJsMessageQueue.EvalBridgeMode(this, cordova)); bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue); exposeJsInterface(webView, bridge); }