Search in sources :

Example 1 with CordovaBridge

use of org.apache.cordova.CordovaBridge in project cordova-android by apache.

the class SystemWebViewEngine method init.

@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);
}
Also used : NativeToJsMessageQueue(org.apache.cordova.NativeToJsMessageQueue) CordovaBridge(org.apache.cordova.CordovaBridge)

Aggregations

CordovaBridge (org.apache.cordova.CordovaBridge)1 NativeToJsMessageQueue (org.apache.cordova.NativeToJsMessageQueue)1