當前位置: 首頁>>代碼示例>>Java>>正文


Java WritableMap.putDouble方法代碼示例

本文整理匯總了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;
}
 
開發者ID:salathegroup,項目名稱:react-native-scandit,代碼行數:26,代碼來源:ReactBridgeHelpers.java

示例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));
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:22,代碼來源:ReactWebViewManager.java

示例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);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:22,代碼來源:ReactRootView.java

示例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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:19,代碼來源:LocationModule.java

示例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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:25,代碼來源:DeviceInfoModule.java

示例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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:14,代碼來源:ReactTextInputEvent.java

示例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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:30,代碼來源:ScrollEvent.java

示例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());
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:13,代碼來源:DatePickerDialogTestCase.java

示例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);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:8,代碼來源:ContentSizeChangeEvent.java

示例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;
}
 
開發者ID:toystars,項目名稱:react-native-geo-fence,代碼行數:20,代碼來源:RNGeoFenceModule.java

示例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);
}
 
開發者ID:marshmelloX,項目名稱:react-native-stt,代碼行數:8,代碼來源:SpeechRecognitionListener.java

示例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;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:12,代碼來源:ReactContentSizeChangedEvent.java

示例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;
}
 
開發者ID:ccm-innovation,項目名稱:react-native-twilio-chat,代碼行數:41,代碼來源:RCTConvert.java

示例15: serializeEventData

import com.facebook.react.bridge.WritableMap; //導入方法依賴的package包/類
private WritableMap serializeEventData() {
  WritableMap eventData = Arguments.createMap();
  eventData.putDouble("drawerState", getDrawerState());
  return eventData;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:6,代碼來源:DrawerStateChangedEvent.java


注:本文中的com.facebook.react.bridge.WritableMap.putDouble方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。