@ReactProp(name = ViewProps.MAX_HEIGHT) public void setMaxHeight(Dynamic maxHeight) { if (isVirtual()) { return; } mTempYogaValue.setFromDynamic(maxHeight); switch (mTempYogaValue.unit) { case POINT: case UNDEFINED: setStyleMaxHeight(mTempYogaValue.value); break; case PERCENT: setStyleMaxHeightPercent(mTempYogaValue.value); break; } maxHeight.recycle(); }
@ReactProp(name = "keyboardType") public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) { int flagsToSet = InputType.TYPE_CLASS_TEXT; if (KEYBOARD_TYPE_NUMERIC.equalsIgnoreCase(keyboardType)) { flagsToSet = INPUT_TYPE_KEYBOARD_NUMBERED; } else if (KEYBOARD_TYPE_EMAIL_ADDRESS.equalsIgnoreCase(keyboardType)) { flagsToSet = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT; } else if (KEYBOARD_TYPE_PHONE_PAD.equalsIgnoreCase(keyboardType)) { flagsToSet = InputType.TYPE_CLASS_PHONE; } updateStagedInputTypeFlag( view, INPUT_TYPE_KEYBOARD_NUMBERED | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_CLASS_TEXT, flagsToSet); checkPasswordType(view); }
@ReactProp(name = "profile") public void setProfile(AspectFrameLayout view, @Nullable ReadableMap profile) { ReadableMap video = profile.getMap("video"); ReadableMap audio = profile.getMap("audio"); int encodingSize = profile.getInt("encodingSize"); StreamingProfile.AudioProfile aProfile = new StreamingProfile.AudioProfile(audio.getInt("rate"), audio.getInt("bitrate")); //audio sample rate, audio bitrate StreamingProfile.VideoProfile vProfile = new StreamingProfile.VideoProfile(video.getInt("fps"), video.getInt("bps"), video.getInt("maxFrameInterval"));//fps bps maxFrameInterval StreamingProfile.AVProfile avProfile = new StreamingProfile.AVProfile(vProfile, aProfile); mProfile.setAVProfile(avProfile); mProfile.setEncodingSizeLevel(encodingSize); mMediaStreamingManager.setStreamingProfile(mProfile); }
@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); } }
@ReactProp(name = ViewProps.MIN_HEIGHT) public void setMinHeight(Dynamic minHeight) { if (isVirtual()) { return; } mTempYogaValue.setFromDynamic(minHeight); switch (mTempYogaValue.unit) { case POINT: case UNDEFINED: setStyleMinHeight(mTempYogaValue.value); break; case PERCENT: setStyleMinHeightPercent(mTempYogaValue.value); break; } minHeight.recycle(); }
@ReactProp(name = ViewProps.FONT_WEIGHT) public void setFontWeight(@Nullable String fontWeightString) { final int fontWeight; if (fontWeightString == null) { fontWeight = -1; } else if (BOLD.equals(fontWeightString)) { fontWeight = Typeface.BOLD; } else if (NORMAL.equals(fontWeightString)) { fontWeight = Typeface.NORMAL; } else { int fontWeightNumeric = parseNumericFontWeight(fontWeightString); if (fontWeightNumeric == -1) { throw new RuntimeException("invalid font weight " + fontWeightString); } fontWeight = fontWeightNumeric >= 500 ? Typeface.BOLD : Typeface.NORMAL; } if (mFontStylingSpan.getFontWeight() != fontWeight) { getSpan().setFontWeight(fontWeight); notifyChanged(true); } }
@ReactProp(name = "barCodeTypes") public void setBarCodeTypes(RCTCameraView view, ReadableArray barCodeTypes) { if (barCodeTypes == null) { return; } List<String> result = new ArrayList<String>(barCodeTypes.size()); for (int i = 0; i < barCodeTypes.size(); i++) { result.add(barCodeTypes.getString(i)); } view.setBarCodeTypes(result); }
@Test(expected = RuntimeException.class) public void testUnsupportedPropValueType() { new BaseViewManager() { @ReactProp(name = "prop") public void setterWithUnsupportedValueType(View v, Date value) { } }.getNativeProps(); }
@ReactProp(name = "clipping") public void setClipping(@Nullable ReadableArray clippingDims) { float[] clippingData = PropHelper.toFloatArray(clippingDims); if (clippingData != null) { mClipping = createClipping(clippingData); markUpdated(); } }
@ReactProp(name = PROP_TRANSFORM) public void setTransform(T view, ReadableArray matrix) { if (matrix == null) { resetTransformProperty(view); } else { setTransformProperty(view, matrix); } }
@ReactProp(name = "zoom") public void setZoom(AspectFrameLayout view, int zoom) { mCurrentZoom = zoom; mCurrentZoom = Math.min(mCurrentZoom, mMaxZoom); mCurrentZoom = Math.max(0, mCurrentZoom); mMediaStreamingManager.setZoomValue(zoom); }
@ReactProp(name = "source") public void setSource(final CrosswalkWebView view, @Nullable ReadableMap source) { Activity _activity = reactContext.getCurrentActivity(); if (_activity != null) { if (source != null) { if (source.hasKey("html")) { final String html = source.getString("html"); _activity.runOnUiThread(new Runnable() { @Override public void run () { view.load(null, html); } }); return; } if (source.hasKey("uri")) { final String url = source.getString("uri"); _activity.runOnUiThread(new Runnable() { @Override public void run () { view.load(url, null); } }); return; } } } setUrl(view, BLANK_URL); }
@ReactProp(name = "captureMode") public void setCaptureMode(RCTCameraView view, final int captureMode) { // Note that this in practice only performs any additional setup necessary for each mode; // the actual indication to capture a still or record a video when capture() is called is // still ultimately decided upon by what it in the options sent to capture(). view.setCaptureMode(captureMode); }
@Test(expected = RuntimeException.class) public void testSetterWIthNonViewParam() { new BaseViewManager() { @ReactProp(name = "prop") public void setterWithNonViewParam(Object v, boolean value) { } }.getNativeProps(); }
@ReactProp(name = "expandedTitleMargin") public void setExpandedTitleMargin(CollapsingToolbarLayoutView view, ReadableMap margin) { int start = margin.getInt("start"); int top = margin.getInt("top"); int end = margin.getInt("end"); int bottom = margin.getInt("bottom"); view.setExpandedTitleMargin( (int) PixelUtil.toPixelFromDIP(start), (int) PixelUtil.toPixelFromDIP(top), (int) PixelUtil.toPixelFromDIP(end), (int) PixelUtil.toPixelFromDIP(bottom) ); }
@ReactProp(name = ViewProps.JUSTIFY_CONTENT) public void setJustifyContent(@Nullable String justifyContent) { if (isVirtual()) { return; } if (justifyContent == null) { setJustifyContent(YogaJustify.FLEX_START); return; } switch (justifyContent) { case "flex-start": { setJustifyContent(YogaJustify.FLEX_START); break; } case "center": { setJustifyContent(YogaJustify.CENTER); break; } case "flex-end": { setJustifyContent(YogaJustify.FLEX_END); break; } case "space-between": { setJustifyContent(YogaJustify.SPACE_BETWEEN); break; } case "space-around": { setJustifyContent(YogaJustify.SPACE_AROUND); break; } default: { throw new JSApplicationIllegalArgumentException( "invalid value for justifyContent: " + justifyContent); } } }
@ReactProp(name = "placeholderTextColor", customType = "Color") public void setPlaceholderTextColor(ReactEditText view, @Nullable Integer color) { if (color == null) { view.setHintTextColor(DefaultStyleValuesUtil.getDefaultTextColorHint(view.getContext())); } else { view.setHintTextColor(color); } }
@ReactProp(name = PROP_SHADOW_RADIUS, defaultInt = 1) public void setTextShadowRadius(float textShadowRadius) { if (textShadowRadius != mTextShadowRadius) { mTextShadowRadius = textShadowRadius; markUpdated(); } }
@ReactProp(name = ViewProps.RESIZE_METHOD) public void setResizeMethod(ReactImageView view, @Nullable String resizeMethod) { if (resizeMethod == null || "auto".equals(resizeMethod)) { view.setResizeMethod(ImageResizeMethod.AUTO); } else if ("resize".equals(resizeMethod)) { view.setResizeMethod(ImageResizeMethod.RESIZE); } else if ("scale".equals(resizeMethod)) { view.setResizeMethod(ImageResizeMethod.SCALE); } else { throw new JSApplicationIllegalArgumentException("Invalid resize method: '" + resizeMethod+ "'"); } }
@ReactProp(name = ViewProps.LINE_HEIGHT, defaultInt = UNSET) public void setLineHeight(int lineHeight) { mLineHeightInput = lineHeight; if (lineHeight == UNSET) { mLineHeight = Float.NaN; } else { mLineHeight = mAllowFontScaling ? PixelUtil.toPixelFromSP(lineHeight) : PixelUtil.toPixelFromDIP(lineHeight); } markUpdated(); }
@ReactProp(name = "items") public void setItems(ReactPicker view, @Nullable ReadableArray items) { if (items != null) { ReadableMap[] data = new ReadableMap[items.size()]; for (int i = 0; i < items.size(); i++) { data[i] = items.getMap(i); } ReactPickerAdapter adapter = new ReactPickerAdapter(view.getContext(), data); adapter.setPrimaryTextColor(view.getPrimaryColor()); view.setAdapter(adapter); } else { view.setAdapter(null); } }
@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); // } }
@ReactProp(name = "trackTintColor", customType = "Color") public void setTrackTintColor(ReactSwitch view, Integer color) { if (color == null) { view.getTrackDrawable().clearColorFilter(); } else { view.getTrackDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } }
@ReactProp(name = "userAgent") public void setUserAgent(WebView view, @Nullable String userAgent) { if (userAgent != null) { // TODO(8496850): Fix incorrect behavior when property is unset (uA == null) view.getSettings().setUserAgentString(userAgent); } }
@ReactProp(name = "onContentSizeChange") public void setOnContentSizeChange(WebView view, boolean sendContentSizeChangeEvents) { if (sendContentSizeChangeEvents) { view.setPictureListener(getPictureListener()); } else { view.setPictureListener(null); } }
@ReactProp(name = "started") public void setStarted(PLVideoView mVideoView, boolean started) { this.started = started; if (started) { mVideoView.start(); } else { mVideoView.pause(); mEventEmitter.receiveEvent(getTargetId(), Events.PAUSE.toString(), Arguments.createMap()); } }
@ReactProp(name = PROP_REPEAT, defaultBoolean = false) public void setRepeat(final ReactExoplayerView videoView, final boolean repeat) { videoView.setRepeatModifier(repeat); }
@ReactProp(name = PROP_TEXT) public void setText(@Nullable String text) { mText = text; markUpdated(); }
@ReactProp(name = "shouldNotifyLoadEvents") public void setLoadHandlersRegistered(ReactImageView view, boolean shouldNotifyLoadEvents) { view.setShouldNotifyLoadEvents(shouldNotifyLoadEvents); }
@ReactProp(name = "fadeDuration") public void setFadeDuration(int durationMs) { getMutableDrawImage().setFadeDuration(durationMs); }
@ReactProp(name = PROP_PROGRESS) public void setProgress(ProgressBarContainerView view, double progress) { view.setProgress(progress); }
@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_GET_AV_FRAME_TIMEOUT, avFrameTimeout); } // Some optimization with buffering mechanism when be set to 1 if (liveStreaming) { options.setInteger(AVOptions.KEY_LIVE_STREAMING, 1); } else { options.setInteger(AVOptions.KEY_LIVE_STREAMING, 0); } // } // 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); // } }
@ReactProp(name = "bar") public void setBar(View view, ReadableMap bar) { }
@ReactProp(name = PROP_MUTED, defaultBoolean = false) public void setMuted(final ReactVideoView videoView, final boolean muted) { videoView.setMutedModifier(muted); }
@ReactProp(name = PROP_TEXT) public void setText(@Nullable String text) { mText = text; notifyChanged(true); }
@ReactProp(name = com.facebook.react.uimanager.ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS) public void setRemoveClippedSubviews(ReactViewGroup view, boolean removeClippedSubviews) { view.setRemoveClippedSubviews(removeClippedSubviews); }
@ReactProp(name = PROP_RATE) public void setRate(final ReactVideoView videoView, final float rate) { videoView.setRateModifier(rate); }