Java 类com.facebook.yoga.YogaMeasureOutput 实例源码

项目:react-native-twitterkit    文件:TweetShadowNode.java   
public synchronized long measure(
        Tweet tweet,
        YogaNode node,
        float width,
        YogaMeasureMode widthMode,
        float height,
        YogaMeasureMode heightMode
) {
  if (mTweetView == null) {
    mTweetView = ReactTweetViewManager.createTweetView(getThemedContext());
  }

  if (tweet != null) {
    mTweetView.setTweet(tweet);
  }
  mTweetView.measure(yogaToAndroid(widthMode, width), yogaToAndroid(heightMode, height));

  int measuredWidth = mTweetView.getMeasuredWidth();
  int measuredHeight = mTweetView.getMeasuredHeight();
  return YogaMeasureOutput.make(measuredWidth, measuredHeight);
}
项目:RNLearn_Project1    文件:RCTTextInput.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  int fontSize = getFontSize();
  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      fontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : fontSize);

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));
  return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
项目:RNLearn_Project1    文件:ReactSwitchManager.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  if (!mMeasured) {
    // Create a switch with the default config and measure it; since we don't (currently)
    // support setting custom switch text, this is fine, as all switches will measure the same
    // on a specific device/theme/locale combination.
    ReactSwitch reactSwitch = new ReactSwitch(getThemedContext());
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSwitch.measure(spec, spec);
    mWidth = reactSwitch.getMeasuredWidth();
    mHeight = reactSwitch.getMeasuredHeight();
    mMeasured = true;
  }

  return YogaMeasureOutput.make(mWidth, mHeight);
}
项目:RNLearn_Project1    文件:ProgressBarShadowNode.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
  if (!mMeasured.contains(style)) {
    ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    progressBar.measure(spec, spec);
    mHeight.put(style, progressBar.getMeasuredHeight());
    mWidth.put(style, progressBar.getMeasuredWidth());
    mMeasured.add(style);
  }

  return YogaMeasureOutput.make(mWidth.get(style), mHeight.get(style));
}
项目:RNLearn_Project1    文件:ReactSliderManager.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  if (!mMeasured) {
    SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSlider.measure(spec, spec);
    mWidth = reactSlider.getMeasuredWidth();
    mHeight = reactSlider.getMeasuredHeight();
    mMeasured = true;
  }

  return YogaMeasureOutput.make(mWidth, mHeight);
}
项目:RNLearn_Project1    文件:RCTTextInput.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  int fontSize = getFontSize();
  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      fontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : fontSize);

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));
  return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
项目:RNLearn_Project1    文件:ReactSwitchManager.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  if (!mMeasured) {
    // Create a switch with the default config and measure it; since we don't (currently)
    // support setting custom switch text, this is fine, as all switches will measure the same
    // on a specific device/theme/locale combination.
    ReactSwitch reactSwitch = new ReactSwitch(getThemedContext());
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSwitch.measure(spec, spec);
    mWidth = reactSwitch.getMeasuredWidth();
    mHeight = reactSwitch.getMeasuredHeight();
    mMeasured = true;
  }

  return YogaMeasureOutput.make(mWidth, mHeight);
}
项目:RNLearn_Project1    文件:ProgressBarShadowNode.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  final int style = ReactProgressBarViewManager.getStyleFromString(getStyle());
  if (!mMeasured.contains(style)) {
    ProgressBar progressBar = ReactProgressBarViewManager.createProgressBar(getThemedContext(), style);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    progressBar.measure(spec, spec);
    mHeight.put(style, progressBar.getMeasuredHeight());
    mWidth.put(style, progressBar.getMeasuredWidth());
    mMeasured.add(style);
  }

  return YogaMeasureOutput.make(mWidth.get(style), mHeight.get(style));
}
项目:RNLearn_Project1    文件:ReactSliderManager.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  if (!mMeasured) {
    SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE);
    final int spec = View.MeasureSpec.makeMeasureSpec(
        ViewGroup.LayoutParams.WRAP_CONTENT,
        View.MeasureSpec.UNSPECIFIED);
    reactSlider.measure(spec, spec);
    mWidth = reactSlider.getMeasuredWidth();
    mHeight = reactSlider.getMeasuredHeight();
    mMeasured = true;
  }

  return YogaMeasureOutput.make(mWidth, mHeight);
}
项目:RNLearn_Project1    文件:RCTText.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {

  CharSequence text = getText();
  if (TextUtils.isEmpty(text)) {
    // to indicate that we don't have anything to display
    mText = null;
    return YogaMeasureOutput.make(0, 0);
  } else {
    mText = text;
  }

  Layout layout = createTextLayout(
      (int) Math.ceil(width),
      widthMode,
      TextUtils.TruncateAt.END,
      true,
      mNumberOfLines,
      mNumberOfLines == 1,
      text,
      getFontSize(),
      mSpacingAdd,
      mSpacingMult,
      getFontStyle(),
      getAlignment());

  if (mDrawCommand != null && !mDrawCommand.isFrozen()) {
    mDrawCommand.setLayout(layout);
  } else {
    mDrawCommand = new DrawTextLayout(layout);
  }

  return YogaMeasureOutput.make(mDrawCommand.getLayoutWidth(), mDrawCommand.getLayoutHeight());
}
项目:RNLearn_Project1    文件:ReactTextInputShadowNode.java   
@Override
public long measure(
    YogaNode node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      mFontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (editText.getBreakStrategy() != mTextBreakStrategy) {
      editText.setBreakStrategy(mTextBreakStrategy);
    }
  }

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));

  return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
项目:RNLearn_Project1    文件:RCTText.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {

  CharSequence text = getText();
  if (TextUtils.isEmpty(text)) {
    // to indicate that we don't have anything to display
    mText = null;
    return YogaMeasureOutput.make(0, 0);
  } else {
    mText = text;
  }

  Layout layout = createTextLayout(
      (int) Math.ceil(width),
      widthMode,
      TextUtils.TruncateAt.END,
      true,
      mNumberOfLines,
      mNumberOfLines == 1,
      text,
      getFontSize(),
      mSpacingAdd,
      mSpacingMult,
      getFontStyle(),
      getAlignment());

  if (mDrawCommand != null && !mDrawCommand.isFrozen()) {
    mDrawCommand.setLayout(layout);
  } else {
    mDrawCommand = new DrawTextLayout(layout);
  }

  return YogaMeasureOutput.make(mDrawCommand.getLayoutWidth(), mDrawCommand.getLayoutHeight());
}
项目:RNLearn_Project1    文件:ReactTextInputShadowNode.java   
@Override
public long measure(
    YogaNodeAPI node,
    float width,
    YogaMeasureMode widthMode,
    float height,
    YogaMeasureMode heightMode) {
  // measure() should never be called before setThemedContext()
  EditText editText = Assertions.assertNotNull(mEditText);

  editText.setTextSize(
      TypedValue.COMPLEX_UNIT_PX,
      mFontSize == UNSET ?
          (int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);

  if (mNumberOfLines != UNSET) {
    editText.setLines(mNumberOfLines);
  }

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    if (editText.getBreakStrategy() != mTextBreakStrategy) {
      editText.setBreakStrategy(mTextBreakStrategy);
    }
  }

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));

  return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
项目:react-native-bottom-sheet-behavior    文件:FloatingActionButtonShadowNode.java   
@Override
public long measure(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) {
    if(!mMeasured) {
        FloatingActionButtonView nodeView = new FloatingActionButtonView(getThemedContext());
        final int spec = View.MeasureSpec.makeMeasureSpec(
                ViewGroup.LayoutParams.WRAP_CONTENT,
                View.MeasureSpec.UNSPECIFIED);
        nodeView.measure(spec, spec);
        mWidth = nodeView.getMeasuredWidth();
        mHeight = nodeView.getMeasuredHeight();
        mMeasured = true;
    }

    return YogaMeasureOutput.make(mWidth, mHeight);
}