本文整理汇总了Java中com.facebook.react.bridge.ReadableMap.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ReadableMap.getDouble方法的具体用法?Java ReadableMap.getDouble怎么用?Java ReadableMap.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.ReadableMap
的用法示例。
在下文中一共展示了ReadableMap.getDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例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: FrameBasedAnimationDriver
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
FrameBasedAnimationDriver(ReadableMap config) {
ReadableArray frames = config.getArray("frames");
int numberOfFrames = frames.size();
mFrames = new double[numberOfFrames];
for (int i = 0; i < numberOfFrames; i++) {
mFrames[i] = frames.getDouble(i);
}
mToValue = config.getDouble("toValue");
mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
mCurrentLoop = 1;
mHasFinished = mIterations == 0;
}
示例4: extractMapValue
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
private Object extractMapValue(ReadableMap params, HashMap<String, Object> paramsMap, String key) {
Object mapValue;
if (ReadableType.Number == params.getType(key)) {
try {
mapValue = params.getInt(key);
} catch (UnexpectedNativeTypeException e) {
mapValue = params.getDouble(key);
}
} else {
mapValue = paramsMap.get(key);
}
return mapValue;
}
示例5: setCoordinate
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
public void setCoordinate(ReadableMap coordinate) {
if (coordinate == null ) return;
Double lng = coordinate.getDouble("longitude");
Double lat = coordinate.getDouble("latitude");
// Saving to local variable as panorama may not be ready yet (async)
this.coordinate = new LatLng(lat, lng);
}
示例6: 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);
}
示例7: fromReactMap
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
private static LocationOptions fromReactMap(ReadableMap map) {
// precision might be dropped on timeout (double -> int conversion), but that's OK
long timeout =
map.hasKey("timeout") ? (long) map.getDouble("timeout") : Long.MAX_VALUE;
double maximumAge =
map.hasKey("maximumAge") ? map.getDouble("maximumAge") : Double.POSITIVE_INFINITY;
boolean highAccuracy =
map.hasKey("enableHighAccuracy") && map.getBoolean("enableHighAccuracy");
float distanceFilter = map.hasKey("distanceFilter") ?
(float) map.getDouble("distanceFilter") :
RCT_DEFAULT_LOCATION_ACCURACY;
return new LocationOptions(timeout, maximumAge, highAccuracy, distanceFilter);
}
示例8: DecayAnimation
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
public DecayAnimation(ReadableMap config) {
mVelocity = config.getDouble("velocity");
mDeceleration = config.getDouble("deceleration");
mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
mCurrentLoop = 1;
mHasFinished = mIterations == 0;
}
示例9: SpringAnimation
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
SpringAnimation(ReadableMap config) {
mSpringFriction = config.getDouble("friction");
mSpringTension = config.getDouble("tension");
mCurrentState.velocity = config.getDouble("initialVelocity");
mEndValue = config.getDouble("toValue");
mRestSpeedThreshold = config.getDouble("restSpeedThreshold");
mDisplacementFromRestThreshold = config.getDouble("restDisplacementThreshold");
mOvershootClampingEnabled = config.getBoolean("overshootClamping");
mIterations = config.hasKey("iterations") ? config.getInt("iterations") : 1;
mHasFinished = mIterations == 0;
}
示例10: receiveEvent
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
@Override
public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
if (event == null) {
throw new IllegalArgumentException("Native animated events must have event data.");
}
// Get the new value for the node by looking into the event map using the provided event path.
ReadableMap curMap = event;
for (int i = 0; i < mEventPath.size() - 1; i++) {
curMap = curMap.getMap(mEventPath.get(i));
}
mValueNode.mValue = curMap.getDouble(mEventPath.get(mEventPath.size() - 1));
}
示例11: DiffClampAnimatedNode
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
public DiffClampAnimatedNode(
ReadableMap config,
NativeAnimatedNodesManager nativeAnimatedNodesManager) {
mNativeAnimatedNodesManager = nativeAnimatedNodesManager;
mInputNodeTag = config.getInt("input");
mMin = config.getDouble("min");
mMax = config.getDouble("max");
mValue = mLastValue = 0;
}
示例12: matches
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
/**
* User to find notifications:
* <p>
* https://github.com/facebook/react-native/blob/master/Libraries/PushNotificationIOS/RCTPushNotificationManager.m#L294
*
* @param userInfo map of fields to match
* @return true all fields in userInfo object match, false otherwise
*/
public boolean matches(ReadableMap userInfo) {
Bundle bundle = toBundle();
ReadableMapKeySetIterator iterator = userInfo.keySetIterator();
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
if (!bundle.containsKey(key))
return false;
switch (userInfo.getType(key)) {
case Null: {
if (bundle.get(key) != null)
return false;
break;
}
case Boolean: {
if (userInfo.getBoolean(key) != bundle.getBoolean(key))
return false;
break;
}
case Number: {
if ((userInfo.getDouble(key) != bundle.getDouble(key)) && (userInfo.getInt(key) != bundle.getInt(key)))
return false;
break;
}
case String: {
if (!userInfo.getString(key).equals(bundle.getString(key)))
return false;
break;
}
case Map:
return false;//there are no maps in the bundle
case Array:
return false;//there are no arrays in the bundle
}
}
return true;
}
示例13: ValueAnimatedNode
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
public ValueAnimatedNode(ReadableMap config) {
mValue = config.getDouble("value");
mOffset = config.getDouble("offset");
}
示例14: applyTextPropertiesToPaint
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
private void applyTextPropertiesToPaint(Paint paint) {
int alignment = mTextAlignment;
switch (alignment) {
case TEXT_ALIGNMENT_LEFT:
paint.setTextAlign(Paint.Align.LEFT);
break;
case TEXT_ALIGNMENT_RIGHT:
paint.setTextAlign(Paint.Align.RIGHT);
break;
case TEXT_ALIGNMENT_CENTER:
paint.setTextAlign(Paint.Align.CENTER);
break;
}
if (mFrame != null) {
if (mFrame.hasKey(PROP_FONT)) {
ReadableMap font = mFrame.getMap(PROP_FONT);
if (font != null) {
float fontSize = DEFAULT_FONT_SIZE;
if (font.hasKey(PROP_FONT_SIZE)) {
fontSize = (float) font.getDouble(PROP_FONT_SIZE);
}
paint.setTextSize(fontSize * mScale);
boolean isBold =
font.hasKey(PROP_FONT_WEIGHT) && "bold".equals(font.getString(PROP_FONT_WEIGHT));
boolean isItalic =
font.hasKey(PROP_FONT_STYLE) && "italic".equals(font.getString(PROP_FONT_STYLE));
int fontStyle;
if (isBold && isItalic) {
fontStyle = Typeface.BOLD_ITALIC;
} else if (isBold) {
fontStyle = Typeface.BOLD;
} else if (isItalic) {
fontStyle = Typeface.ITALIC;
} else {
fontStyle = Typeface.NORMAL;
}
// NB: if the font family is null / unsupported, the default one will be used
paint.setTypeface(Typeface.create(font.getString(PROP_FONT_FAMILY), fontStyle));
}
}
}
}
示例15: deleteWeight
import com.facebook.react.bridge.ReadableMap; //导入方法依赖的package包/类
public boolean deleteWeight(ReadableMap weightSample) {
DateFormat dateFormat = DateFormat.getDateInstance();
long endTime = (long) weightSample.getDouble("endTime");
long startTime = (long) weightSample.getDouble("startTime");
new DeleteDataTask(startTime, endTime).execute();
return true;
}