Java 类com.facebook.react.views.view.MeasureUtil 实例源码

项目: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    文件: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    文件: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    文件: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());
}
项目:Ironman    文件:ReactTextInputShadowNode.java   
@Override
public void measure(
    CSSNodeAPI node,
    float width,
    CSSMeasureMode widthMode,
    float height,
    CSSMeasureMode heightMode,
    MeasureOutput measureOutput) {
  // 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);
  mComputedPadding = new float[] {
      getPadding(Spacing.START),
      getPadding(Spacing.TOP),
      getPadding(Spacing.END),
      getPadding(Spacing.BOTTOM),
  };
  editText.setPadding(
      (int) Math.floor(getPadding(Spacing.START)),
      (int) Math.floor(getPadding(Spacing.TOP)),
      (int) Math.floor(getPadding(Spacing.END)),
      (int) Math.floor(getPadding(Spacing.BOTTOM)));

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

  editText.measure(
      MeasureUtil.getMeasureSpec(width, widthMode),
      MeasureUtil.getMeasureSpec(height, heightMode));
  measureOutput.width = editText.getMeasuredWidth();
  measureOutput.height = editText.getMeasuredHeight();
}