Java 类org.apache.cordova.NativeToJsMessageQueue 实例源码

项目:keemob    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:PreCogSecurity.github.io    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:krakn    文件:XWalkCordovaWebView.java   
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
        Whitelist whitelist, CordovaPreferences preferences) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    this.cordova = cordova;
    this.whitelist = whitelist;
    this.preferences = preferences;

    pluginManager = new PluginManager(this, this.cordova, pluginEntries);
    resourceApi = new CordovaResourceApi(webview.getContext(), pluginManager);
    bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
    pluginManager.addService("App", "org.apache.cordova.CoreAndroid");
    initWebViewSettings();

    webview.init(this);
    exposeJsInterface();
}
项目:krakn    文件:XWalkCordovaWebView.java   
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
        Whitelist whitelist, CordovaPreferences preferences) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    this.cordova = cordova;
    this.whitelist = whitelist;
    this.preferences = preferences;

    pluginManager = new PluginManager(this, this.cordova, pluginEntries);
    resourceApi = new CordovaResourceApi(webview.getContext(), pluginManager);
    bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
    pluginManager.addService("App", "org.apache.cordova.CoreAndroid");
    initWebViewSettings();

    webview.init(this);
    exposeJsInterface();
}
项目:krakn    文件:XWalkCordovaWebView.java   
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
        Whitelist whitelist, CordovaPreferences preferences) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    this.cordova = cordova;
    this.whitelist = whitelist;
    this.preferences = preferences;

    pluginManager = new PluginManager(this, this.cordova, pluginEntries);
    resourceApi = new CordovaResourceApi(webview.getContext(), pluginManager);
    bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
    pluginManager.addService("App", "org.apache.cordova.CoreAndroid");
    initWebViewSettings();

    webview.init(this);
    exposeJsInterface();
}
项目:krakn    文件:XWalkCordovaWebView.java   
@Override
public void init(CordovaInterface cordova, List<PluginEntry> pluginEntries,
        Whitelist whitelist, CordovaPreferences preferences) {
    if (this.cordova != null) {
        throw new IllegalStateException();
    }
    this.cordova = cordova;
    this.whitelist = whitelist;
    this.preferences = preferences;

    pluginManager = new PluginManager(this, this.cordova, pluginEntries);
    resourceApi = new CordovaResourceApi(webview.getContext(), pluginManager);
    bridge = new CordovaBridge(pluginManager, new NativeToJsMessageQueue(this, cordova));
    pluginManager.addService("App", "org.apache.cordova.CoreAndroid");
    initWebViewSettings();

    webview.init(this);
    exposeJsInterface();
}
项目:cordova-mozillaview-engine    文件:CordovaGeckoViewEngine.java   
@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);
}
项目:radioflow    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:COB    文件:SystemWebViewEngine.java   
@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);
   }
项目:cordova-vuetify    文件:SystemWebViewEngine.java   
@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);
   }
项目:x5webview-cordova-plugin    文件:X5WebViewEngine.java   
@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);
}
项目:keemob    文件:SystemWebViewEngine.java   
@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);
   }
项目:keemob    文件:NativeToJsMessageQueueTest.java   
@Test
public void testEnabledBridge()
{
    NativeToJsMessageQueue.BridgeMode bridge;
    bridge = new NativeToJsMessageQueue.NoOpBridgeMode();
    queue.addBridgeMode(bridge);
    queue.setBridgeMode(0);
    assertTrue(queue.isBridgeEnabled());
}
项目:keemob    文件:NativeToJsMessageQueueTest.java   
@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]);
}
项目:keemob    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:keemob    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:keemob    文件:NativeToJsMessageQueueTest.java   
@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);");
}
项目:keemob    文件:SystemWebViewEngine.java   
@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);
   }
项目:cordova-plugin-x5-tbs    文件:X5WebViewEngine.java   
@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);
}
项目:alerta-fraude    文件:SystemWebViewEngine.java   
@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);
   }
项目:localcloud_fe    文件:SystemWebViewEngine.java   
@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);
   }
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@Test
public void testEnabledBridge()
{
    NativeToJsMessageQueue.BridgeMode bridge;
    bridge = new NativeToJsMessageQueue.NoOpBridgeMode();
    queue.addBridgeMode(bridge);
    queue.setBridgeMode(0);
    assertTrue(queue.isBridgeEnabled());
}
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@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]);
}
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@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"));
}
项目:localcloud_fe    文件:NativeToJsMessageQueueTest.java   
@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);");
}
项目:localcloud_fe    文件:SystemWebViewEngine.java   
@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);
   }
项目:siiMobilityAppKit    文件:SystemWebViewEngine.java   
@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);
   }
项目:cordova.plugins.X5WebView    文件:X5WebViewEngine.java   
@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);
   }
项目:DinningShare    文件:SystemWebViewEngine.java   
@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);
   }
项目:resin-configurator-client    文件:SystemWebViewEngine.java   
@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);
}
项目:react-native-web-utf8map    文件:SystemWebViewEngine.java   
@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);
}
项目:HybridAppReduxVsIonic    文件:SystemWebViewEngine.java   
@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);
}
项目:cordova-plugin-crosswalk-webview    文件:XWalkWebViewEngine.java   
@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);
        }
    }));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
}
项目:cordova-photosphere-example    文件:XWalkWebViewEngine.java   
@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);

    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);
        }
    }));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
}
项目:cordova-photosphere-example    文件:SystemWebViewEngine.java   
@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);
}
项目:cordova-photosphere-example    文件:XWalkWebViewEngine.java   
@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);

    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);
        }
    }));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
}
项目:ShaPaoZi-Mobile    文件:XWalkWebViewEngine.java   
@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);

    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);
        }
    }));
    bridge = new CordovaBridge(pluginManager, nativeToJsMessageQueue);
}
项目:ShaPaoZi-Mobile    文件:SystemWebViewEngine.java   
@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);
}