本文整理汇总了Java中com.facebook.react.bridge.WritableMap.putDouble方法的典型用法代码示例。如果您正苦于以下问题:Java WritableMap.putDouble方法的具体用法?Java WritableMap.putDouble怎么用?Java WritableMap.putDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.bridge.WritableMap
的用法示例。
在下文中一共展示了WritableMap.putDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertJsonToMap
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
map.putArray(key, convertJsonToArray((JSONArray) value));
} else if (value instanceof Boolean) {
map.putBoolean(key, (Boolean) value);
} else if (value instanceof Integer) {
map.putInt(key, (Integer) value);
} else if (value instanceof Double) {
map.putDouble(key, (Double) value);
} else if (value instanceof String) {
map.putString(key, (String) value);
} else {
map.putString(key, value.toString());
}
}
return map;
}
示例2: onReceivedError
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void onReceivedError(
WebView webView,
int errorCode,
String description,
String failingUrl) {
super.onReceivedError(webView, errorCode, description, failingUrl);
mLastLoadFailed = true;
// In case of an error JS side expect to get a finish event first, and then get an error event
// Android WebView does it in the opposite way, so we need to simulate that behavior
emitFinishEvent(webView, failingUrl);
WritableMap eventData = createWebViewEvent(webView, failingUrl);
eventData.putDouble("code", errorCode);
eventData.putString("description", description);
dispatchEvent(
webView,
new TopLoadingErrorEvent(webView.getId(), eventData));
}
示例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: 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;
}
示例5: 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;
}
示例6: serializeEventData
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private WritableMap serializeEventData() {
WritableMap eventData = Arguments.createMap();
WritableMap range = Arguments.createMap();
range.putDouble("start", mRangeStart);
range.putDouble("end", mRangeEnd);
eventData.putString("text", mText);
eventData.putString("previousText", mPreviousText);
eventData.putMap("range", range);
eventData.putInt("target", getViewTag());
return eventData;
}
示例7: serializeEventData
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private WritableMap serializeEventData() {
WritableMap contentInset = Arguments.createMap();
contentInset.putDouble("top", 0);
contentInset.putDouble("bottom", 0);
contentInset.putDouble("left", 0);
contentInset.putDouble("right", 0);
WritableMap contentOffset = Arguments.createMap();
contentOffset.putDouble("x", PixelUtil.toDIPFromPixel(mScrollX));
contentOffset.putDouble("y", PixelUtil.toDIPFromPixel(mScrollY));
WritableMap contentSize = Arguments.createMap();
contentSize.putDouble("width", PixelUtil.toDIPFromPixel(mContentWidth));
contentSize.putDouble("height", PixelUtil.toDIPFromPixel(mContentHeight));
WritableMap layoutMeasurement = Arguments.createMap();
layoutMeasurement.putDouble("width", PixelUtil.toDIPFromPixel(mScrollViewWidth));
layoutMeasurement.putDouble("height", PixelUtil.toDIPFromPixel(mScrollViewHeight));
WritableMap event = Arguments.createMap();
event.putMap("contentInset", contentInset);
event.putMap("contentOffset", contentOffset);
event.putMap("contentSize", contentSize);
event.putMap("layoutMeasurement", layoutMeasurement);
event.putInt("target", getViewTag());
event.putBoolean("responderIgnoreScroll", true);
return event;
}
示例8: testPresetDate
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public void testPresetDate() {
final WritableMap options = new WritableNativeMap();
options.putDouble("date", getDateInMillis(2020, 5, 6));
final DialogFragment datePickerFragment = showDialog(options);
final DatePicker datePicker =
((DatePickerDialog) datePickerFragment.getDialog()).getDatePicker();
assertEquals(2020, datePicker.getYear());
assertEquals(5, datePicker.getMonth());
assertEquals(6, datePicker.getDayOfMonth());
}
示例9: dispatch
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
WritableMap data = Arguments.createMap();
data.putDouble("width", PixelUtil.toDIPFromPixel(mWidth));
data.putDouble("height", PixelUtil.toDIPFromPixel(mHeight));
rctEventEmitter.receiveEvent(getViewTag(), EVENT_NAME, data);
}
示例10: resolveLocationQueryPromise
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
/**
* Resolves the pending promise for user current location request
*
* @param Location location to use for promise resolve
*
* @return void
*/
private void resolveLocationQueryPromise(Location location) {
if (pendingPromise != null) {
WritableMap writableMap = new WritableNativeMap();
writableMap.putDouble("longitude", location.getLongitude());
writableMap.putDouble("latitude", location.getLatitude());
writableMap.putString("provider", location.getProvider());
writableMap.putDouble("accuracy", location.getAccuracy());
writableMap.putDouble("altitude", location.getAltitude());
pendingPromise.resolve(writableMap);
}
pendingPromise = null;
}
示例11: setDefaultPitch
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@ReactMethod
public void setDefaultPitch(float pitch, Promise promise) {
if(notReady(promise)) return;
int result = tts.setPitch(pitch);
if(result == TextToSpeech.SUCCESS) {
WritableMap map = Arguments.createMap();
map.putString("status", "Success");
map.putDouble("pitch", (double)pitch);
promise.resolve(map);
} else {
promise.reject("error", "Unable to set pitch");
}
}
开发者ID:echo8795,项目名称:react-native-android-text-to-speech,代码行数:15,代码来源:RNAndroidTextToSpeechModule.java
示例12: onRmsChanged
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
@Override
public void onRmsChanged(float rmsdB) {
Logger.debug(TAG, "onRmsChanged: " + rmsdB);
WritableMap data = Arguments.createMap();
data.putDouble("rmsdB", rmsdB);
emit(SPEECH_TO_TEXT, data);
}
示例13: serializeEventData
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private WritableMap serializeEventData() {
WritableMap eventData = Arguments.createMap();
WritableMap contentSize = Arguments.createMap();
contentSize.putDouble("width", mContentWidth);
contentSize.putDouble("height", mContentHeight);
eventData.putMap("contentSize", contentSize);
eventData.putInt("target", getViewTag());
return eventData;
}
示例14: jsonToWritableMap
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
public static WritableMap jsonToWritableMap(JSONObject jsonObject) {
WritableMap writableMap = new WritableNativeMap();
if (jsonObject == null) {
return null;
}
Iterator<String> iterator = jsonObject.keys();
if (!iterator.hasNext()) {
return null;
}
try {
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value == null) {
writableMap.putNull(key);
} else if (value instanceof Boolean) {
writableMap.putBoolean(key, (Boolean) value);
} else if (value instanceof Integer) {
writableMap.putInt(key, (Integer) value);
} else if (value instanceof Double) {
writableMap.putDouble(key, (Double) value);
} else if (value instanceof String) {
writableMap.putString(key, (String) value);
} else if (value instanceof JSONObject) {
writableMap.putMap(key, jsonToWritableMap((JSONObject) value));
} else if (value instanceof JSONArray) {
writableMap.putArray(key, jsonArrayToWritableArray((JSONArray) value));
}
}
} catch (JSONException ex){
// Do nothing and fail silently
}
return writableMap;
}
示例15: serializeEventData
import com.facebook.react.bridge.WritableMap; //导入方法依赖的package包/类
private WritableMap serializeEventData() {
WritableMap eventData = Arguments.createMap();
eventData.putDouble("drawerState", getDrawerState());
return eventData;
}