本文整理汇总了Java中com.facebook.react.bridge.WritableMap.merge方法的典型用法代码示例。如果您正苦于以下问题:Java WritableMap.merge方法的具体用法?Java WritableMap.merge怎么用?Java WritableMap.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.WritableMap
的用法示例。
在下文中一共展示了WritableMap.merge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMapMerging
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public void testMapMerging() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapForMerge1();
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapForMerge2();
waitForBridgeAndUIIdle();
List<ReadableMap> maps = mRecordingTestModule.getMapCalls();
assertEquals(2, maps.size());
WritableMap dest = new WritableNativeMap();
dest.merge(maps.get(0));
dest.merge(maps.get(1));
assertTrue(dest.hasKey("a"));
assertTrue(dest.hasKey("b"));
assertTrue(dest.hasKey("c"));
assertTrue(dest.hasKey("d"));
assertTrue(dest.hasKey("e"));
assertTrue(dest.hasKey("f"));
assertTrue(dest.hasKey("newkey"));
assertEquals("overwrite", dest.getString("a"));
assertEquals(41, dest.getInt("b"));
assertEquals("string", dest.getString("c"));
assertEquals(77, dest.getInt("d"));
assertTrue(dest.isNull("e"));
assertEquals(3, dest.getArray("f").size());
assertEquals("newvalue", dest.getString("newkey"));
}
示例2: testMapAccessibleAfterMerge
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public void testMapAccessibleAfterMerge() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapForMerge1();
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnMapForMerge2();
waitForBridgeAndUIIdle();
List<ReadableMap> maps = mRecordingTestModule.getMapCalls();
assertEquals(2, maps.size());
WritableMap dest = new WritableNativeMap();
dest.merge(maps.get(0));
dest.merge(maps.get(1));
ReadableMap source = maps.get(1);
assertTrue(source.hasKey("a"));
assertTrue(source.hasKey("d"));
assertTrue(source.hasKey("e"));
assertTrue(source.hasKey("f"));
assertTrue(source.hasKey("newkey"));
assertFalse(source.hasKey("b"));
assertFalse(source.hasKey("c"));
assertEquals("overwrite", source.getString("a"));
assertEquals(77, source.getInt("d"));
assertTrue(source.isNull("e"));
assertEquals(3, source.getArray("f").size());
assertEquals("newvalue", source.getString("newkey"));
}
示例3: onHandleIntent
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
/**
* Handles incoming intents.
* @param intent sent by Location Services. This Intent is provided to Location
* Services (inside a PendingIntent) when addGeofences() is called.
*/
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
if (geofencingEvent.hasError()) {
String errorMessage = GeofenceErrorMessages.getErrorString(this,
geofencingEvent.getErrorCode());
Log.e(TAG, errorMessage);
return;
}
// Get the transition type.
int geofenceTransition = geofencingEvent.getGeofenceTransition();
// Test that the reported transition was of interest.
if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER ||
geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {
// Get the geofences that were triggered. A single event can trigger multiple geofences.
List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();
WritableArray writableArray = new WritableNativeArray();
for (int i = 0; i < triggeringGeofences.size(); i++) {
Geofence geofence = triggeringGeofences.get(i);
String key = geofence.getRequestId();
ReadableMap geofenceMap = getGeofenceFromKey(key);
WritableMap writableMap = new WritableNativeMap();
writableMap.merge(geofenceMap);
writableMap.putString("transition", getTransitionString(geofenceTransition));
writableArray.pushMap(writableMap);
}
// create final event emitter object argument
WritableMap finalEventEmitterObject = new WritableNativeMap();
finalEventEmitterObject.putArray("data", writableArray);
finalEventEmitterObject.putString("event", "geofenceTrigger");
SReactApplicationContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit("GeofenceEvent", finalEventEmitterObject);
} else {
// Log the error.
Log.e(TAG, "Geofence transition error: invalid transition type " + geofenceTransition);
}
}