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