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


Java ReadableMap.hasKey方法代碼示例

本文整理匯總了Java中com.facebook.react.bridge.ReadableMap.hasKey方法的典型用法代碼示例。如果您正苦於以下問題:Java ReadableMap.hasKey方法的具體用法?Java ReadableMap.hasKey怎麽用?Java ReadableMap.hasKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.facebook.react.bridge.ReadableMap的用法示例。


在下文中一共展示了ReadableMap.hasKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPhotos

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Get photos from {@link MediaStore.Images}, most recent first.
 *
 * @param params a map containing the following keys:
 *        <ul>
 *          <li>first (mandatory): a number representing the number of photos to fetch</li>
 *          <li>
 *            after (optional): a cursor that matches page_info[end_cursor] returned by a
 *            previous call to {@link #getPhotos}
 *          </li>
 *          <li>groupName (optional): an album name</li>
 *          <li>
 *            mimeType (optional): restrict returned images to a specific mimetype (e.g.
 *            image/jpeg)
 *          </li>
 *        </ul>
 * @param promise the Promise to be resolved when the photos are loaded; for a format of the
 *        parameters passed to this callback, see {@code getPhotosReturnChecker} in CameraRoll.js
 */
@ReactMethod
public void getPhotos(final ReadableMap params, final Promise promise) {
  int first = params.getInt("first");
  String after = params.hasKey("after") ? params.getString("after") : null;
  String groupName = params.hasKey("groupName") ? params.getString("groupName") : null;
  ReadableArray mimeTypes = params.hasKey("mimeTypes")
      ? params.getArray("mimeTypes")
      : null;
  if (params.hasKey("groupTypes")) {
    throw new JSApplicationIllegalArgumentException("groupTypes is not supported on Android");
  }

  new GetPhotosTask(
        getReactApplicationContext(),
        first,
        after,
        groupName,
        mimeTypes,
        promise)
        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:41,代碼來源:CameraRollManager.java

示例2: getSourceIdConstraint

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Retreives "sourceId" constraint value.
 * @param mediaConstraints a <tt>ReadableMap</tt> which represents "GUM"
 * constraints argument
 * @return String value of "sourceId" optional "GUM" constraint or
 * <tt>null</tt> if not specified in the given map.
 */
private String getSourceIdConstraint(ReadableMap mediaConstraints) {
    if (mediaConstraints.hasKey("optional")
            && mediaConstraints.getType("optional") == ReadableType.Array) {
        ReadableArray optional = mediaConstraints.getArray("optional");

        for (int i = 0, size = optional.size(); i < size; i++) {
            if (optional.getType(i) == ReadableType.Map) {
                ReadableMap option = optional.getMap(i);

                if (option.hasKey("sourceId")
                        && option.getType("sourceId") == ReadableType.String) {
                    return option.getString("sourceId");
                }
            }
        }
    }
    return null;
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:26,代碼來源:WebRTCModule.java

示例3: getMapStrValue

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Reads a value from given <tt>ReadableMap</tt> and returns it as
 * a <tt>String</tt>. Note that integer value is converted to double, before
 * it gets converted to a string.
 * @param map the <tt>ReadableMap</tt> from which the value will be obtained
 * @param key the map's key under which the value has been mapped.
 * @return a <tt>String</tt> representation of the value if exists or
 * <tt>null</tt> if there is no value mapped for given <tt>key</tt>.
 */
public static String getMapStrValue(ReadableMap map, String key) {
    if(!map.hasKey(key)){
        return null;
    }
    ReadableType type = map.getType(key);
    switch (type) {
        case Boolean:
            return String.valueOf(map.getBoolean(key));
        case Number:
            // Don't know how to distinguish between Int and Double from
            // ReadableType.Number. 'getInt' will fail on double value,
            // while 'getDouble' works for both.
            // return String.valueOf(map.getInt(key));
            return String.valueOf(map.getDouble(key));
        case String:
            return map.getString(key);
        default:
            return null;
    }
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:30,代碼來源:ReactBridgeUtil.java

示例4: setTextShadowOffset

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = PROP_SHADOW_OFFSET)
public void setTextShadowOffset(@Nullable ReadableMap offsetMap) {
  float dx = 0;
  float dy = 0;
  if (offsetMap != null) {
    if (offsetMap.hasKey("width")) {
      dx = PixelUtil.toPixelFromDIP(offsetMap.getDouble("width"));
    }
    if (offsetMap.hasKey("height")) {
      dy = PixelUtil.toPixelFromDIP(offsetMap.getDouble("height"));
    }
  }

  if (!mShadowStyleSpan.offsetMatches(dx, dy)) {
    getShadowSpan().setOffset(dx, dy);
    notifyChanged(false);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:19,代碼來源:RCTVirtualText.java

示例5: stackTraceToString

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private String stackTraceToString(String message, ReadableArray stack) {
  StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n");
  for (int i = 0; i < stack.size(); i++) {
    ReadableMap frame = stack.getMap(i);
    stringBuilder
        .append(frame.getString("methodName"))
        .append("@")
        .append(stackFrameToModuleId(frame))
        .append(frame.getInt("lineNumber"));
    if (frame.hasKey("column") &&
        !frame.isNull("column") &&
        frame.getType("column") == ReadableType.Number) {
      stringBuilder
          .append(":")
          .append(frame.getInt("column"));
    }
    stringBuilder.append("\n");
  }
  return stringBuilder.toString();
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:21,代碼來源:ExceptionsManagerModule.java

示例6: getView

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
private View getView(int position, View convertView, ViewGroup parent, boolean isDropdown) {
  ReadableMap item = getItem(position);

  if (convertView == null) {
    int layoutResId = isDropdown
        ? android.R.layout.simple_spinner_dropdown_item
        : android.R.layout.simple_spinner_item;
    convertView = mInflater.inflate(layoutResId, parent, false);
  }

  TextView textView = (TextView) convertView;
  textView.setText(item.getString("label"));
  if (!isDropdown && mPrimaryTextColor != null) {
    textView.setTextColor(mPrimaryTextColor);
  } else if (item.hasKey("color") && !item.isNull("color")) {
    textView.setTextColor(item.getInt("color"));
  }

  return convertView;
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:21,代碼來源:ReactPickerManager.java

示例7: setActions

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
void setActions(@Nullable ReadableArray actions) {
  Menu menu = getMenu();
  menu.clear();
  mActionsHolder.clear();
  if (actions != null) {
    for (int i = 0; i < actions.size(); i++) {
      ReadableMap action = actions.getMap(i);

      MenuItem item = menu.add(Menu.NONE, Menu.NONE, i, action.getString(PROP_ACTION_TITLE));

      if (action.hasKey(PROP_ACTION_ICON)) {
        setMenuItemIcon(item, action.getMap(PROP_ACTION_ICON));
      }

      int showAsAction = action.hasKey(PROP_ACTION_SHOW)
          ? action.getInt(PROP_ACTION_SHOW)
          : MenuItem.SHOW_AS_ACTION_NEVER;
      if (action.hasKey(PROP_ACTION_SHOW_WITH_TEXT) &&
          action.getBoolean(PROP_ACTION_SHOW_WITH_TEXT)) {
        showAsAction = showAsAction | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
      }
      item.setShowAsAction(showAsAction);
    }
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:26,代碼來源:ReactToolbar.java

示例8: initPush

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactMethod
public void initPush(final ReadableMap options){
    allocServer = options.getString("allocServer");
    String userId = options.getString("userId");
    String tags = options.getString("tags");
    String publicKey = options.getString("publicKey");
    String version = options.hasKey("version") ? options.getString("version") : "1.0.0";

    if(TextUtils.isEmpty(allocServer) || TextUtils.isEmpty(userId) || TextUtils.isEmpty(publicKey)) return;

    //公鑰有服務端提供和私鑰對應
    @SuppressLint("HardwareIds")
    String deviceId = Settings.Secure.getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    ClientConfig cc = ClientConfig.build()
            .setPublicKey(publicKey)
            .setAllotServer(allocServer)
            .setDeviceId(deviceId)
            .setClientVersion(version)
            .setLogger(new MPushLog())
            .setLogEnabled(BuildConfig.DEBUG)
            .setEnableHttpProxy(true)
            .setUserId(userId).setTags(tags);
    MPush.I.checkInit(getReactApplicationContext()).setClientConfig(cc);
}
 
開發者ID:stulip,項目名稱:react-native-mpush,代碼行數:25,代碼來源:RCTMPushModule.java

示例9: initializeFromConfig

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public void initializeFromConfig(final @Nullable ReadableMap config) {
  if (!ENABLED) {
    return;
  }

  if (config == null) {
    reset();
    return;
  }

  mShouldAnimateLayout = false;
  int globalDuration = config.hasKey("duration") ? config.getInt("duration") : 0;
  if (config.hasKey(LayoutAnimationType.CREATE.toString())) {
    mLayoutCreateAnimation.initializeFromConfig(
        config.getMap(LayoutAnimationType.CREATE.toString()), globalDuration);
    mShouldAnimateLayout = true;
  }
  if (config.hasKey(LayoutAnimationType.UPDATE.toString())) {
    mLayoutUpdateAnimation.initializeFromConfig(
        config.getMap(LayoutAnimationType.UPDATE.toString()), globalDuration);
    mShouldAnimateLayout = true;
  }
  if (config.hasKey(LayoutAnimationType.DELETE.toString())) {
    mLayoutDeleteAnimation.initializeFromConfig(
        config.getMap(LayoutAnimationType.DELETE.toString()), globalDuration);
    mShouldAnimateLayout = true;
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:29,代碼來源:LayoutAnimationController.java

示例10: parseMediaConstraints

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Parses mandatory and optional "GUM" constraints described by a specific
 * <tt>ReadableMap</tt>.
 *
 * @param constraints A <tt>ReadableMap</tt> which represents a JavaScript
 * object specifying the constraints to be parsed into a
 * <tt>MediaConstraints</tt> instance.
 * @return A new <tt>MediaConstraints</tt> instance initialized with the
 * mandatory and optional constraint keys and values specified by
 * <tt>constraints</tt>.
 */
private MediaConstraints parseMediaConstraints(ReadableMap constraints) {
    MediaConstraints mediaConstraints = new MediaConstraints();

    if (constraints.hasKey("mandatory")
            && constraints.getType("mandatory") == ReadableType.Map) {
        parseConstraints(
                constraints.getMap("mandatory"),
                mediaConstraints.mandatory);
    } else {
        Log.d(TAG, "mandatory constraints are not a map");
    }

    if (constraints.hasKey("optional")
            && constraints.getType("optional") == ReadableType.Array) {
        ReadableArray optional = constraints.getArray("optional");

        for (int i = 0, size = optional.size(); i < size; i++) {
            if (optional.getType(i) == ReadableType.Map) {
                parseConstraints(
                        optional.getMap(i),
                        mediaConstraints.optional);
            }
        }
    } else {
        Log.d(TAG, "optional constraints are not an array");
    }

    return mediaConstraints;
}
 
開發者ID:angellsl10,項目名稱:react-native-webrtc,代碼行數:41,代碼來源:WebRTCModule.java

示例11: stackFrameToModuleId

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
static private String stackFrameToModuleId(ReadableMap frame) {
  if (frame.hasKey("file") &&
      !frame.isNull("file") &&
      frame.getType("file") == ReadableType.String) {
    final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file"));
    if (matcher.find()) {
      return matcher.group(1) + ":";
    }
  }
  return "";
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:12,代碼來源:ExceptionsManagerModule.java

示例12: hasAndNotEmpty

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
public static @NonNull boolean hasAndNotEmpty(@NonNull final ReadableMap target,
                                              @NonNull final String key)
{
    if (!target.hasKey(key))
    {
        return false;
    }

    final String value = target.getString(key);

    return !TextUtils.isEmpty(value);
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:13,代碼來源:UdeskModule.java

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

示例14: setSource

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
@ReactProp(name = "source")
    public void setSource(PLVideoView mVideoView, ReadableMap source) {
        AVOptions options = new AVOptions();
        String uri = source.getString("uri");
        boolean mediaController = source.hasKey("controller") && source.getBoolean("controller");
        int avFrameTimeout = source.hasKey("timeout") ? source.getInt("timeout") : -1;        //10 * 1000 ms
        //boolean liveStreaming = source.hasKey("live") && source.getBoolean("live");  //1 or 0 // 1 -> live
        boolean codec = source.hasKey("hardCodec") && source.getBoolean("hardCodec");  //1 or 0  // 1 -> hw codec enable, 0 -> disable [recommended]
        // the unit of timeout is ms
        if (avFrameTimeout >= 0) {
            options.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, avFrameTimeout);
        }
        // Some optimization with buffering mechanism when be set to 1
        options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
//        }

        // 1 -> hw codec enable, 0 -> disable [recommended]
        if (codec) {
            options.setInteger(AVOptions.KEY_MEDIACODEC, 1);
        } else {
            options.setInteger(AVOptions.KEY_MEDIACODEC, 0);
        }

        mVideoView.setAVOptions(options);

        // After setVideoPath, the play will start automatically
        // mVideoView.start() is not required

        mVideoView.setVideoPath(uri);

//        if (mediaController) {
//            // You can also use a custom `MediaController` widget
//            MediaController mMediaController = new MediaController(reactContext, false, isLiveStreaming(uri));
//            mVideoView.setMediaController(mMediaController);
//        }

    }
 
開發者ID:An-uking,項目名稱:react-native-pili-player,代碼行數:38,代碼來源:PiliLiveViewManager.java

示例15: extractHeaders

import com.facebook.react.bridge.ReadableMap; //導入方法依賴的package包/類
/**
 * Extracts the headers from the Array. If the format is invalid, this method will return null.
 */
private @Nullable Headers extractHeaders(
    @Nullable ReadableArray headersArray,
    @Nullable ReadableMap requestData) {
  if (headersArray == null) {
    return null;
  }
  Headers.Builder headersBuilder = new Headers.Builder();
  for (int headersIdx = 0, size = headersArray.size(); headersIdx < size; headersIdx++) {
    ReadableArray header = headersArray.getArray(headersIdx);
    if (header == null || header.size() != 2) {
      return null;
    }
    String headerName = header.getString(0);
    String headerValue = header.getString(1);
    if (headerName == null || headerValue == null) {
      return null;
    }
    headersBuilder.add(headerName, headerValue);
  }
  if (headersBuilder.get(USER_AGENT_HEADER_NAME) == null && mDefaultUserAgent != null) {
    headersBuilder.add(USER_AGENT_HEADER_NAME, mDefaultUserAgent);
  }

  // Sanitize content encoding header, supported only when request specify payload as string
  boolean isGzipSupported = requestData != null && requestData.hasKey(REQUEST_BODY_KEY_STRING);
  if (!isGzipSupported) {
    headersBuilder.removeAll(CONTENT_ENCODING_HEADER_NAME);
  }

  return headersBuilder.build();
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:35,代碼來源:NetworkingModule.java


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