本文整理匯總了Java中org.apache.cordova.NativeToJsMessageQueue類的典型用法代碼示例。如果您正苦於以下問題:Java NativeToJsMessageQueue類的具體用法?Java NativeToJsMessageQueue怎麽用?Java NativeToJsMessageQueue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NativeToJsMessageQueue類屬於org.apache.cordova包,在下文中一共展示了NativeToJsMessageQueue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testJsonPopAndEncodeAsJs
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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"));
}
示例2: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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();
}
示例3: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例4: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例5: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例6: testEnabledBridge
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@Test
public void testEnabledBridge()
{
NativeToJsMessageQueue.BridgeMode bridge;
bridge = new NativeToJsMessageQueue.NoOpBridgeMode();
queue.addBridgeMode(bridge);
queue.setBridgeMode(0);
assertTrue(queue.isBridgeEnabled());
}
示例7: testPopAndEncode
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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]);
}
示例8: testBasicPopAndEncodeAsJs
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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"));
}
示例9: testStringPopAndEncodeAsJs
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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"));
}
示例10: testMultipartPopAndEncodeAsJs
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);");
}
示例11: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例12: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例13: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例14: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}
示例15: init
import org.apache.cordova.NativeToJsMessageQueue; //導入依賴的package包/類
@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);
}