本文整理匯總了Java中com.facebook.react.bridge.ReadableMap.getMap方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableMap.getMap方法的具體用法?Java ReadableMap.getMap怎麽用?Java ReadableMap.getMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.facebook.react.bridge.ReadableMap
的用法示例。
在下文中一共展示了ReadableMap.getMap方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setProfile
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "profile")
public void setProfile(AspectFrameLayout view, @Nullable ReadableMap profile) {
ReadableMap video = profile.getMap("video");
ReadableMap audio = profile.getMap("audio");
int encodingSize = profile.getInt("encodingSize");
StreamingProfile.AudioProfile aProfile =
new StreamingProfile.AudioProfile(audio.getInt("rate"), audio.getInt("bitrate")); //audio sample rate, audio bitrate
StreamingProfile.VideoProfile vProfile =
new StreamingProfile.VideoProfile(video.getInt("fps"), video.getInt("bps"), video.getInt("maxFrameInterval"));//fps bps maxFrameInterval
StreamingProfile.AVProfile avProfile = new StreamingProfile.AVProfile(vProfile, aProfile);
mProfile.setAVProfile(avProfile);
mProfile.setEncodingSizeLevel(encodingSize);
mMediaStreamingManager.setStreamingProfile(mProfile);
}
示例2: writeLocationExifData
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private void writeLocationExifData(ReadableMap options, ExifInterface exif) {
if(!options.hasKey("metadata"))
return;
ReadableMap metadata = options.getMap("metadata");
if (!metadata.hasKey("location"))
return;
ReadableMap location = metadata.getMap("location");
if(!location.hasKey("coords"))
return;
try {
ReadableMap coords = location.getMap("coords");
double latitude = coords.getDouble("latitude");
double longitude = coords.getDouble("longitude");
GPS.writeExifData(latitude, longitude, exif);
} catch (IOException e) {
Log.e(TAG, "Couldn't write location data", e);
}
}
示例3: mapGetByType
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private void mapGetByType(ReadableMap map, String key, String typeToAskFor) {
if (typeToAskFor.equals("double")) {
map.getDouble(key);
} else if (typeToAskFor.equals("int")) {
map.getInt(key);
} else if (typeToAskFor.equals("string")) {
map.getString(key);
} else if (typeToAskFor.equals("array")) {
map.getArray(key);
} else if (typeToAskFor.equals("map")) {
map.getMap(key);
} else if (typeToAskFor.equals("boolean")) {
map.getBoolean(key);
} else {
throw new RuntimeException("Unknown type: " + typeToAskFor);
}
}
示例4: setProfile
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "profile")
public void setProfile(View view, @Nullable ReadableMap profile) {
ReadableMap audio = profile.getMap("audio");
StreamingProfile.VideoProfile vProfile =
new StreamingProfile.VideoProfile(0,0,0);//hack for bad API
StreamingProfile.AudioProfile aProfile =
new StreamingProfile.AudioProfile(audio.getInt("rate"), audio.getInt("bitrate")); //audio sample rate, audio bitrate
StreamingProfile.AVProfile avProfile = new StreamingProfile.AVProfile(vProfile, aProfile);
mProfile.setAVProfile(avProfile);
mMediaStreamingManager.setStreamingProfile(mProfile);
}
示例5: setUserInfo
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactMethod
public void setUserInfo(final ReadableMap options, final Callback callback) {
Map<String, String> info = new HashMap<>();
if (!hasAndNotEmpty(options, "sdk_token")) {
return;
}
String token = options.getString("sdk_token");
if (token == null) {
token = UUID.randomUUID().toString();
}
//token 必填
info.put(UdeskConst.UdeskUserInfo.USER_SDK_TOKEN, token);
//以下信息是可選
if (hasAndNotEmpty(options, "nick_name")) {
info.put(UdeskConst.UdeskUserInfo.NICK_NAME, options.getString("nick_name"));
}
if (hasAndNotEmpty(options, "email")) {
info.put(UdeskConst.UdeskUserInfo.EMAIL, options.getString("email"));
}
if (hasAndNotEmpty(options, "cellphone")) {
info.put(UdeskConst.UdeskUserInfo.CELLPHONE, options.getString("cellphone"));
}
if (hasAndNotEmpty(options, "description")) {
info.put(UdeskConst.UdeskUserInfo.DESCRIPTION, options.getString("description"));
}
ReadableMap field = options.getMap("customer_field");
if (field!= null && field.hasKey("TextField_10075")) {
Map<String, String> fields = new HashMap<>();
fields.put("TextField_10075", field.getString("TextField_10075"));
UdeskSDKManager.getInstance().setUserInfo(mReactContext.getApplicationContext(), token, info, fields);
} else {
UdeskSDKManager.getInstance().setUserInfo(mReactContext.getApplicationContext(), token, info);
}
}
示例6: setSource
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "source")
public void setSource(WebView view, @Nullable ReadableMap source) {
if (source != null) {
if (source.hasKey("html")) {
String html = source.getString("html");
if (source.hasKey("baseUrl")) {
view.loadDataWithBaseURL(
source.getString("baseUrl"), html, HTML_MIME_TYPE, HTML_ENCODING, null);
} else {
view.loadData(html, HTML_MIME_TYPE, HTML_ENCODING);
}
return;
}
if (source.hasKey("uri")) {
String url = source.getString("uri");
String previousUrl = view.getUrl();
if (previousUrl != null && previousUrl.equals(url)) {
return;
}
if (source.hasKey("method")) {
String method = source.getString("method");
if (method.equals(HTTP_METHOD_POST)) {
byte[] postData = null;
if (source.hasKey("body")) {
String body = source.getString("body");
try {
postData = body.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
postData = body.getBytes();
}
}
if (postData == null) {
postData = new byte[0];
}
view.postUrl(url, postData);
return;
}
}
HashMap<String, String> headerMap = new HashMap<>();
if (source.hasKey("headers")) {
ReadableMap headers = source.getMap("headers");
ReadableMapKeySetIterator iter = headers.keySetIterator();
while (iter.hasNextKey()) {
String key = iter.nextKey();
if ("user-agent".equals(key.toLowerCase(Locale.ENGLISH))) {
if (view.getSettings() != null) {
view.getSettings().setUserAgentString(headers.getString(key));
}
} else {
headerMap.put(key, headers.getString(key));
}
}
}
view.loadUrl(url, headerMap);
return;
}
}
view.loadUrl(BLANK_URL);
}
示例7: cropImage
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
* Crop an image. If all goes well, the success callback will be called with the file:// URI of
* the new image as the only argument. This is a temporary file - consider using
* CameraRollManager.saveImageWithTag to save it in the gallery.
*
* @param uri the MediaStore URI of the image to crop
* @param options crop parameters specified as {@code {offset: {x, y}, size: {width, height}}}.
* Optionally this also contains {@code {targetSize: {width, height}}}. If this is
* specified, the cropped image will be resized to that size.
* All units are in pixels (not DPs).
* @param success callback to be invoked when the image has been cropped; the only argument that
* is passed to this callback is the file:// URI of the new image
* @param error callback to be invoked when an error occurs (e.g. can't create file etc.)
*/
@ReactMethod
public void cropImage(
String uri,
ReadableMap options,
final Callback success,
final Callback error) {
ReadableMap offset = options.hasKey("offset") ? options.getMap("offset") : null;
ReadableMap size = options.hasKey("size") ? options.getMap("size") : null;
if (offset == null || size == null ||
!offset.hasKey("x") || !offset.hasKey("y") ||
!size.hasKey("width") || !size.hasKey("height")) {
throw new JSApplicationIllegalArgumentException("Please specify offset and size");
}
if (uri == null || uri.isEmpty()) {
throw new JSApplicationIllegalArgumentException("Please specify a URI");
}
CropTask cropTask = new CropTask(
getReactApplicationContext(),
uri,
(int) offset.getDouble("x"),
(int) offset.getDouble("y"),
(int) size.getDouble("width"),
(int) size.getDouble("height"),
success,
error);
if (options.hasKey("displaySize")) {
ReadableMap targetSize = options.getMap("displaySize");
cropTask.setTargetSize(targetSize.getInt("width"), targetSize.getInt("height"));
}
cropTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
示例8: StyleAnimatedNode
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
StyleAnimatedNode(ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
ReadableMap style = config.getMap("style");
ReadableMapKeySetIterator iter = style.keySetIterator();
mPropMapping = new HashMap<>();
while (iter.hasNextKey()) {
String propKey = iter.nextKey();
int nodeIndex = style.getInt(propKey);
mPropMapping.put(propKey, nodeIndex);
}
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
}
示例9: testNestedMap
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public void testNestedMap() {
mCatalystInstance.getJSModule(TestJSToJavaParametersModule.class).returnNestedMap();
waitForBridgeAndUIIdle();
List<ReadableMap> calls = mRecordingTestModule.getMapCalls();
assertEquals(1, calls.size());
ReadableMap map = calls.get(0);
assertNotNull(map);
assertTrue(map.hasKey("weHaveToGoDeeper"));
assertFalse(map.isNull("weHaveToGoDeeper"));
ReadableMap nestedMap = map.getMap("weHaveToGoDeeper");
assertTrue(nestedMap.hasKey("inception"));
assertTrue(nestedMap.getBoolean("inception"));
}
示例10: PropsAnimatedNode
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
PropsAnimatedNode(ReadableMap config, NativeAnimatedNodesManager nativeAnimatedNodesManager) {
ReadableMap props = config.getMap("props");
ReadableMapKeySetIterator iter = props.keySetIterator();
mPropMapping = new HashMap<>();
while (iter.hasNextKey()) {
String propKey = iter.nextKey();
int nodeIndex = props.getInt(propKey);
mPropMapping.put(propKey, nodeIndex);
}
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
}
示例11: getMap
import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private ReadableMap getMap(ReadableMap map, String key) {
if (map.hasKey(key) && map.getType(key) == ReadableType.Map) {
return map.getMap(key);
}
return null;
}