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


Java WritableNativeArray.pushMap方法代码示例

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


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

示例1: 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

示例2: getConstants

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@DoNotStrip
public NativeArray getConstants() {
  BaseJavaModule baseJavaModule = getModule();
  ReactMarker.logMarker(GET_CONSTANTS_START, getName());
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
    .arg("moduleName", getName())
    .flush();
  Map<String, Object> map = baseJavaModule.getConstants();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
    .arg("moduleName", getName())
    .flush();
  ReactMarker.logMarker(CONVERT_CONSTANTS_START, getName());
  WritableNativeMap writableNativeMap;
  try {
    writableNativeMap = Arguments.makeNativeMap(map);
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(writableNativeMap);
  ReactMarker.logMarker(CONVERT_CONSTANTS_END);
  ReactMarker.logMarker(GET_CONSTANTS_END);
  return array;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:27,代码来源:JavaModuleWrapper.java

示例3: getConstants

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@DoNotStrip
public NativeArray getConstants() {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
    .arg("moduleName", getName())
    .flush();
  Map<String, Object> map = getModule().getConstants();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
    .arg("moduleName", getName())
    .flush();
  WritableNativeMap writableNativeMap;
  try {
    writableNativeMap = Arguments.makeNativeMap(map);
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(writableNativeMap);
  return array;
}
 
开发者ID:Right-Men,项目名称:Ironman,代码行数:22,代码来源:JavaModuleWrapper.java

示例4: getInstalledApps

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@ReactMethod
public void getInstalledApps(Promise promise) {
    WritableNativeArray params = new WritableNativeArray();
    PackageManager pm = reactContext.getPackageManager();
    List<ApplicationInfo> apps = pm.getInstalledApplications(0);
    for(ApplicationInfo app : apps) {
        if ((pm.getLaunchIntentForPackage(app.packageName) != null) &&
                !thisApp.equals(app.packageName)) {
            WritableNativeMap param = new WritableNativeMap();
            String appName = app.loadLabel(pm).toString();
            String appPackage = app.packageName;
            String appIcon = saveIcon(appPackage, app.loadIcon(pm));
            //Log.d(TAG, "name: "+appName);
            //Log.d(TAG, "app: "+appPackage);
            //Log.d(TAG, "icon: "+appIcon);
            param.putString("name", appName);
            param.putString("app", appPackage);
            param.putString("icon", appIcon);
            //sendEvent("installedApps", param);
            params.pushMap(param);
        }
    }
    promise.resolve(params);
}
 
开发者ID:nerdyfactory,项目名称:things-notification,代码行数:25,代码来源:NotificationModule.java

示例5: getCameraImages

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@ReactMethod
public void getCameraImages(ReadableMap data, Callback onSuccess) {
    WritableNativeArray result = new WritableNativeArray();

    for(CameraImage imageData : CameraImagesManager.getCameraImages(this.context,
            data.getInt("first"), data.hasKey("after") ? data.getString("after") : "")) {
        WritableMap imageDataMap = new WritableNativeMap();
        imageDataMap.putString("uri", imageData.getLocalPath());
        imageDataMap.putInt("width", imageData.getWidth());
        imageDataMap.putInt("height", imageData.getHeight());
        imageDataMap.putInt("orientation", imageData.getOrientation());
        imageDataMap.putString("timestamp", Long.toString(imageData.getTimestamp()));

        result.pushMap(imageDataMap);
    }

    onSuccess.invoke(result);
}
 
开发者ID:bamlab,项目名称:rn-camera-roll,代码行数:19,代码来源:CameraRollModule.java

示例6: 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

示例7: getConstants

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
@DoNotStrip
public @Nullable NativeArray getConstants() {
  if (!mModuleHolder.getHasConstants()) {
    return null;
  }
  BaseJavaModule baseJavaModule = getModule();
  ReactMarker.logMarker(GET_CONSTANTS_START, getName());
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "Map constants")
    .arg("moduleName", getName())
    .flush();
  Map<String, Object> map = baseJavaModule.getConstants();
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);

  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "WritableNativeMap constants")
    .arg("moduleName", getName())
    .flush();
  ReactMarker.logMarker(CONVERT_CONSTANTS_START, getName());
  WritableNativeMap writableNativeMap;
  try {
    writableNativeMap = Arguments.makeNativeMap(map);
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  }
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(writableNativeMap);
  ReactMarker.logMarker(CONVERT_CONSTANTS_END);
  ReactMarker.logMarker(GET_CONSTANTS_END);
  return array;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:30,代码来源:JavaModuleWrapper.java

示例8: testArrayWithMaps

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public void testArrayWithMaps() {
  WritableNativeMap m1 = new WritableNativeMap();
  WritableNativeMap m2 = new WritableNativeMap();
  m1.putString("m1k1", "m1v1");
  m1.putString("m1k2", "m1v2");
  m2.putString("m2k1", "m2v1");

  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(m1);
  array.pushMap(m2);
  mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveArrayWithMaps(array);
  waitForBridgeAndUIIdle();
  mAssertModule.verifyAssertsAndReset();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:15,代码来源:CatalystNativeJavaToJSArgumentsTestCase.java

示例9: testThrowWhenMapReusedInArray

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public void testThrowWhenMapReusedInArray() {
  boolean gotException = false;
  try {
    WritableNativeArray array1 = new WritableNativeArray();
    WritableNativeArray array2 = new WritableNativeArray();
    WritableNativeMap child = new WritableNativeMap();
    array1.pushMap(child);
    array2.pushMap(child);
  } catch (ObjectAlreadyConsumedException e) {
    gotException = true;
  }
  assertTrue(gotException);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:14,代码来源:CatalystNativeJavaToJSArgumentsTestCase.java

示例10: findReminderByEventId

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
private WritableNativeArray findReminderByEventId(String eventID, long startDate) {

        WritableNativeArray results = new WritableNativeArray();
        ContentResolver cr = reactContext.getContentResolver();
        String selection = "(" + CalendarContract.Reminders.EVENT_ID + " = ?)";

        Cursor cursor = cr.query(CalendarContract.Reminders.CONTENT_URI, new String[]{
                CalendarContract.Reminders.MINUTES
        }, selection, new String[] {eventID}, null);

        while (cursor != null && cursor.moveToNext()) {
            WritableNativeMap alarm = new WritableNativeMap();

            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
            sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
            cal.setTimeInMillis(startDate);
            cal.add(Calendar.MINUTE, Integer.parseInt(cursor.getString(0)));

            alarm.putString("date", sdf.format(cal.getTime()));

            results.pushMap(alarm);
        }

        if (cursor != null) {
            cursor.close();
        }

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

示例11: serializeEvents

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
private WritableNativeArray serializeEvents(Cursor cursor) {
    WritableNativeArray results = new WritableNativeArray();

    while (cursor.moveToNext()) {
        results.pushMap(serializeEvent(cursor));
    }

    cursor.close();

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

示例12: serializeEventCalendars

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
private WritableNativeArray serializeEventCalendars(Cursor cursor) {
    WritableNativeArray results = new WritableNativeArray();

    while (cursor.moveToNext()) {
        results.pushMap(serializeEventCalendar(cursor));
    }

    cursor.close();

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

示例13: Factory

import com.facebook.react.bridge.WritableNativeArray; //导入方法依赖的package包/类
public Factory(WritableNativeMap jscConfig) {
  // TODO (t10707444): use NativeMap, which requires moving NativeMap out of OnLoad.
  WritableNativeArray array = new WritableNativeArray();
  array.pushMap(jscConfig);
  mJSCConfig = array;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:7,代码来源:JSCJavaScriptExecutor.java


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