本文整理匯總了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);
}
}