当前位置: 首页>>代码示例>>Java>>正文


Java WritableNativeArray.pushString方法代码示例

本文整理汇总了Java中com.facebook.react.bridge.WritableNativeArray.pushString方法的典型用法代码示例。如果您正苦于以下问题:Java WritableNativeArray.pushString方法的具体用法?Java WritableNativeArray.pushString怎么用?Java WritableNativeArray.pushString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.react.bridge.WritableNativeArray的用法示例。


在下文中一共展示了WritableNativeArray.pushString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callJavaScript

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@ReactMethod
void callJavaScript() {
    Activity activity = getCurrentActivity();
    if (activity != null) {
        MainApplication application = (MainApplication) activity.getApplication();
        ReactNativeHost reactNativeHost = application.getReactNativeHost();
        ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
        ReactContext reactContext = reactInstanceManager.getCurrentReactContext();

        if (reactContext != null) {
            CatalystInstance catalystInstance = reactContext.getCatalystInstance();
            WritableNativeArray params = new WritableNativeArray();
            params.pushString("Hello, JavaScript!");
            catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
        }
    }
}
 
开发者ID:petterh,项目名称:react-native-android-activity,代码行数:18,代码来源:ActivityStarterModule.java

示例2: testMapWithNullStringValue

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public void testMapWithNullStringValue() {
  WritableNativeMap map = new WritableNativeMap();
  map.putString("string", null);
  map.putArray("array", null);
  map.putMap("map", null);

  WritableNativeArray array = new WritableNativeArray();
  array.pushString(null);
  array.pushArray(null);
  array.pushMap(null);

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class)
      .receiveMapAndArrayWithNullValues(map, array);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:CatalystNativeJavaToJSArgumentsTestCase.java

示例3: calendarAllowedAvailabilitiesFromDBString

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
private WritableNativeArray calendarAllowedAvailabilitiesFromDBString(String dbString) {
    WritableNativeArray availabilitiesStrings = new WritableNativeArray();
    for(String availabilityId: dbString.split(",")) {
        switch(Integer.parseInt(availabilityId)) {
            case CalendarContract.Events.AVAILABILITY_BUSY:
                availabilitiesStrings.pushString("busy");
                break;
            case CalendarContract.Events.AVAILABILITY_FREE:
                availabilitiesStrings.pushString("free");
                break;
            case CalendarContract.Events.AVAILABILITY_TENTATIVE:
                availabilitiesStrings.pushString("tentative");
                break;
        }
    }

    return availabilitiesStrings;
}
 
开发者ID:wmcmahan,项目名称:react-native-calendar-events,代码行数:19,代码来源:CalendarEvents.java

示例4: makeNativeArray

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
/**
 * This method converts a List into a NativeArray.  The data types supported
 * are boolean, int, float, double, and String.  List, Map, and Bundle
 * objects, as well as arrays, containing values of the above types and/or
 * null, or any recursive arrangement of these, are also supported.  The best
 * way to think of this is a way to generate a Java representation of a json
 * list, from Java types which have a natural representation in json.
 */
public static WritableNativeArray makeNativeArray(List objects) {
  WritableNativeArray nativeArray = new WritableNativeArray();
  if (objects == null) {
    return nativeArray;
  }
  for (Object elem : objects) {
    elem = makeNativeObject(elem);
    if (elem == null) {
      nativeArray.pushNull();
    } else if (elem instanceof Boolean) {
      nativeArray.pushBoolean((Boolean) elem);
    } else if (elem instanceof Integer) {
      nativeArray.pushInt((Integer) elem);
    } else if (elem instanceof Double) {
      nativeArray.pushDouble((Double) elem);
    } else if (elem instanceof String) {
      nativeArray.pushString((String) elem);
    } else if (elem instanceof WritableNativeArray) {
      nativeArray.pushArray((WritableNativeArray) elem);
    } else if (elem instanceof WritableNativeMap) {
      nativeArray.pushMap((WritableNativeMap) elem);
    } else {
      throw new IllegalArgumentException("Could not convert " + elem.getClass());
    }
  }
  return nativeArray;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:36,代码来源:Arguments.java

示例5: testArrayWithBasicTypes

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public void testArrayWithBasicTypes() {
  WritableNativeArray array = new WritableNativeArray();
  array.pushString("red panda");
  array.pushDouble(1.19);
  array.pushBoolean(true);
  array.pushNull();

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveArrayWithBasicTypes(array);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:12,代码来源:CatalystNativeJavaToJSArgumentsTestCase.java

示例6: testNestedArray

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public void testNestedArray() {
  WritableNativeArray level1 = new WritableNativeArray();
  WritableNativeArray level2 = new WritableNativeArray();
  WritableNativeArray level3 = new WritableNativeArray();
  level3.pushString("level3");
  level2.pushString("level2");
  level2.pushArray(level3);
  level1.pushString("level1");
  level1.pushArray(level2);

  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveNestedArray(level1);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:CatalystNativeJavaToJSArgumentsTestCase.java


注:本文中的com.facebook.react.bridge.WritableNativeArray.pushString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。