本文整理汇总了Java中com.facebook.react.bridge.WritableMap.putMap方法的典型用法代码示例。如果您正苦于以下问题:Java WritableMap.putMap方法的具体用法?Java WritableMap.putMap怎么用?Java WritableMap.putMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.WritableMap
的用法示例。
在下文中一共展示了WritableMap.putMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Member
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap Member(Member member) {
WritableMap map = Arguments.createMap();
map.putMap("userInfo", UserInfo(member.getUserInfo()));
if (member.getLastConsumedMessageIndex() == null) {
map.putNull("lastConsumedMessageIndex");
}
else {
map.putInt("lastConsumedMessageIndex", member.getLastConsumedMessageIndex().intValue());
}
if (member.getLastConsumptionTimestamp() == null) {
map.putNull("lastConsumptionTimestamp");
}
else {
map.putString("lastConsumptionTimestamp", member.getLastConsumptionTimestamp());
}
return map;
}
示例2: jsonToReact
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap jsonToReact(JSONObject jsonObject) throws JSONException {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = jsonObject.keys();
while(iterator.hasNext()) {
String key = (String) iterator.next();
Object value = jsonObject.get(key);
if (value instanceof Float || value instanceof Double) {
writableMap.putDouble(key, jsonObject.getDouble(key));
} else if (value instanceof Number) {
writableMap.putInt(key, jsonObject.getInt(key));
} else if (value instanceof String) {
writableMap.putString(key, jsonObject.getString(key));
} else if (value instanceof JSONObject) {
writableMap.putMap(key,jsonToReact(jsonObject.getJSONObject(key)));
} else if (value instanceof JSONArray){
writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
} else if (value == JSONObject.NULL){
writableMap.putNull(key);
}
}
return writableMap;
}
示例3: checkForKeyboardEvents
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private void checkForKeyboardEvents() {
getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea);
final int heightDiff =
DisplayMetricsHolder.getWindowDisplayMetrics().heightPixels - mVisibleViewArea.bottom;
if (mKeyboardHeight != heightDiff && heightDiff > mMinKeyboardHeightDetected) {
// keyboard is now showing, or the keyboard height has changed
mKeyboardHeight = heightDiff;
WritableMap params = Arguments.createMap();
WritableMap coordinates = Arguments.createMap();
coordinates.putDouble("screenY", PixelUtil.toDIPFromPixel(mVisibleViewArea.bottom));
coordinates.putDouble("screenX", PixelUtil.toDIPFromPixel(mVisibleViewArea.left));
coordinates.putDouble("width", PixelUtil.toDIPFromPixel(mVisibleViewArea.width()));
coordinates.putDouble("height", PixelUtil.toDIPFromPixel(mKeyboardHeight));
params.putMap("endCoordinates", coordinates);
sendEvent("keyboardDidShow", params);
} else if (mKeyboardHeight != 0 && heightDiff <= mMinKeyboardHeightDetected) {
// keyboard is now hidden
mKeyboardHeight = 0;
sendEvent("keyboardDidHide", null);
}
}
示例4: getDimensionsConstants
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private WritableMap getDimensionsConstants() {
DisplayMetrics windowDisplayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
DisplayMetrics screenDisplayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics();
WritableMap windowDisplayMetricsMap = Arguments.createMap();
windowDisplayMetricsMap.putInt("width", windowDisplayMetrics.widthPixels);
windowDisplayMetricsMap.putInt("height", windowDisplayMetrics.heightPixels);
windowDisplayMetricsMap.putDouble("scale", windowDisplayMetrics.density);
windowDisplayMetricsMap.putDouble("fontScale", mFontScale);
windowDisplayMetricsMap.putDouble("densityDpi", windowDisplayMetrics.densityDpi);
WritableMap screenDisplayMetricsMap = Arguments.createMap();
screenDisplayMetricsMap.putInt("width", screenDisplayMetrics.widthPixels);
screenDisplayMetricsMap.putInt("height", screenDisplayMetrics.heightPixels);
screenDisplayMetricsMap.putDouble("scale", screenDisplayMetrics.density);
screenDisplayMetricsMap.putDouble("fontScale", mFontScale);
screenDisplayMetricsMap.putDouble("densityDpi", screenDisplayMetrics.densityDpi);
WritableMap dimensionsMap = Arguments.createMap();
dimensionsMap.putMap("windowPhysicalPixels", windowDisplayMetricsMap);
dimensionsMap.putMap("screenPhysicalPixels", screenDisplayMetricsMap);
return dimensionsMap;
}
示例5: locationToMap
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private static WritableMap locationToMap(Location location) {
WritableMap map = Arguments.createMap();
WritableMap coords = Arguments.createMap();
coords.putDouble("latitude", location.getLatitude());
coords.putDouble("longitude", location.getLongitude());
coords.putDouble("altitude", location.getAltitude());
coords.putDouble("accuracy", location.getAccuracy());
coords.putDouble("heading", location.getBearing());
coords.putDouble("speed", location.getSpeed());
map.putMap("coords", coords);
map.putDouble("timestamp", location.getTime());
if (android.os.Build.VERSION.SDK_INT >= 18) {
map.putBoolean("mocked", location.isFromMockProvider());
}
return map;
}
示例6: Channel
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap Channel(Channel channel) {
WritableMap map = Arguments.createMap();
map.putString("sid", channel.getSid());
map.putString("friendlyName", channel.getFriendlyName());
map.putString("uniqueName", channel.getUniqueName());
map.putString("status", channel.getStatus().toString());
map.putString("type", channel.getType().toString());
map.putString("synchronizationStatus", channel.getSynchronizationStatus().toString());
map.putString("dateCreated", channel.getDateCreated().toString());
map.putString("dateUpdated", channel.getDateUpdated().toString());
WritableMap attributes = Arguments.createMap();
try {
attributes = jsonToWritableMap(channel.getAttributes());
}
catch (JSONException e) {}
map.putMap("attributes", attributes);
return map;
}
示例7: phoneSignalStrengthsUpdated
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void phoneSignalStrengthsUpdated(SignalStrength signalStrength) {
WritableMap map = Arguments.createMap();
map.putInt("cdmaDbm", signalStrength.getCdmaDbm());
map.putInt("cdmaEcio()", signalStrength.getCdmaEcio());
map.putInt("evdoDbm", signalStrength.getEvdoDbm());
map.putInt("evdoEcio", signalStrength.getEvdoEcio());
map.putInt("evdoSnr", signalStrength.getEvdoSnr());
map.putInt("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
map.putInt("gsmSignalStrength", signalStrength.getGsmSignalStrength());
map.putBoolean("gsm", signalStrength.isGsm());
WritableMap result = Arguments.createMap();
result.putString("type", "LISTEN_SIGNAL_STRENGTHS");
result.putMap("data", map);
sendEvent(PHONE_STATE_LISTENER, result);
}
示例8: putImageInfo
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private static boolean putImageInfo(
ContentResolver resolver,
Cursor photos,
WritableMap node,
int idIndex,
int widthIndex,
int heightIndex) {
WritableMap image = new WritableNativeMap();
Uri photoUri = Uri.withAppendedPath(
Images.Media.EXTERNAL_CONTENT_URI,
photos.getString(idIndex));
image.putString("uri", photoUri.toString());
float width = -1;
float height = -1;
if (IS_JELLY_BEAN_OR_LATER) {
width = photos.getInt(widthIndex);
height = photos.getInt(heightIndex);
}
if (width <= 0 || height <= 0) {
try {
AssetFileDescriptor photoDescriptor = resolver.openAssetFileDescriptor(photoUri, "r");
BitmapFactory.Options options = new BitmapFactory.Options();
// Set inJustDecodeBounds to true so we don't actually load the Bitmap, but only get its
// dimensions instead.
options.inJustDecodeBounds = true;
BitmapFactory.decodeFileDescriptor(photoDescriptor.getFileDescriptor(), null, options);
photoDescriptor.close();
width = options.outWidth;
height = options.outHeight;
} catch (IOException e) {
FLog.e(ReactConstants.TAG, "Could not get width/height for " + photoUri.toString(), e);
return false;
}
}
image.putDouble("width", width);
image.putDouble("height", height);
node.putMap("image", image);
return true;
}
示例9: onReadyForSpeech
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void onReadyForSpeech(Bundle params) {
Logger.debug(TAG, "onReadyForSpeech: " + params);
WritableMap data = Arguments.createMap();
data.putMap("params", Arguments.fromBundle(params));
emit(SPEECH_TO_TEXT, data);
}
示例10: onError
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
WritableMap error = Arguments.createMap();
error.putInt(EVENT_PROP_WHAT, what);
error.putInt(EVENT_PROP_EXTRA, extra);
WritableMap event = Arguments.createMap();
event.putMap(EVENT_PROP_ERROR, error);
mEventEmitter.receiveEvent(getId(), Events.EVENT_ERROR.toString(), event);
return true;
}
示例11: onEvent
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void onEvent(int eventType, Bundle params) {
Logger.debug(TAG, "onEvent: " + eventType);
WritableMap data = Arguments.createMap();
data.putInt("eventType", eventType);
data.putMap("params", Arguments.fromBundle(params));
emit(SPEECH_TO_TEXT, data);
}
示例12: toWritableMap
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap toWritableMap(Map<String, Object> map) {
WritableMap writableMap = Arguments.createMap();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry pair = (Map.Entry)iterator.next();
Object value = pair.getValue();
if (value == null) {
writableMap.putNull((String) pair.getKey());
} else if (value instanceof Boolean) {
writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
} else if (value instanceof Double) {
writableMap.putDouble((String) pair.getKey(), (Double) value);
} else if (value instanceof Integer) {
writableMap.putInt((String) pair.getKey(), (Integer) value);
} else if (value instanceof String) {
writableMap.putString((String) pair.getKey(), (String) value);
} else if (value instanceof Map) {
writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
} else if (value.getClass() != null && value.getClass().isArray()) {
writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
}
iterator.remove();
}
return writableMap;
}
示例13: sendEvent
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private void sendEvent(View view, String eventType, WritableMap event) {
WritableMap nativeEvent = Arguments.createMap();
nativeEvent.putString("type", eventType);
nativeEvent.putMap("event", event);
ReactContext reactContext = (ReactContext) view.getContext();
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(view.getId(), "topChange", nativeEvent);
}
示例14: barcodeToWritableMap
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
static public WritableMap barcodeToWritableMap(Barcode barcode) {
WritableMap map = Arguments.createMap();
map.putInt ("compositeFlag", barcode.getCompositeFlag());
map.putString ("data", barcode.getData());
map.putBoolean("isRecognized", barcode.isRecognized());
map.putBoolean("isGs1DataCarrier", barcode.isGs1DataCarrier());
map.putInt ("symbolCount", barcode.getSymbolCount());
map.putInt ("symbology", barcode.getSymbology());
map.putString ("symbologyName", barcode.getSymbologyName());
map.putMap ("location", quadrilateralToWritableMap(barcode.getLocation()));
return map;
}
示例15: UserInfo
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap UserInfo(UserInfo userInfo) {
WritableMap map = Arguments.createMap();
map.putString("identity", userInfo.getIdentity());
map.putString("friendlyName", userInfo.getFriendlyName());
map.putMap("attributes", jsonToWritableMap(userInfo.getAttributes()));
map.putBoolean("isOnline", userInfo.isOnline());
map.putBoolean("isNotifiable", userInfo.isNotifiable());
return map;
}