com.taobao.weex.dom.flex.FloatUtil Java Examples

The following examples show how to use com.taobao.weex.dom.flex.FloatUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXTextDomObject.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
public void layoutAfter() {
  if (hasBeenMeasured) {
    if (layout != null &&
        !FloatUtil.floatsEqual(WXDomUtils.getContentWidth(this), previousWidth)) {
      recalculateLayout();
    }
  } else {
    updateStyleAndText();
    recalculateLayout();
  }
  hasBeenMeasured = false;
  if (layout != null && !layout.equals(atomicReference.get()) &&
      Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //TODO Warm up, a profile should be used to see the improvement.
    warmUpTextLayoutCache(layout);
  }
  swap();
  super.layoutAfter();
}
 
Example #2
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void layoutAfter() {
  if (hasBeenMeasured) {
    if (layout != null &&
        !FloatUtil.floatsEqual(WXDomUtils.getContentWidth(this), previousWidth)) {
      recalculateLayout();
    }
  } else {
    updateStyleAndText();
    recalculateLayout();
  }
  hasBeenMeasured = false;
  if (layout != null && !layout.equals(atomicReference.get()) &&
      Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //TODO Warm up, a profile should be used to see the improvement.
    warmUpTextLayoutCache(layout);
  }
  swap();
  super.layoutAfter();
}
 
Example #3
Source File: WXTextDomObject.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public void layoutAfter() {
  if(hasBeenMeasured){
    if(layout!=null&& !FloatUtil.floatsEqual(getTextContentWidth(),previousWidth)){
      recalculateLayout();
    }
  }
  else{
    updateStyleAndText();
    recalculateLayout();
  }
  hasBeenMeasured =false;

  if(layout!=null && !layout.equals(atomicReference.get()) &&
     Build.VERSION.SDK_INT>=Build.VERSION_CODES.KITKAT) {
    //TODO Warm up, a profile should be used to see the improvement.
    warmUpTextLayoutCache();
  }
  swap();
  super.layoutAfter();
}
 
Example #4
Source File: WXBackgroundDrawable.java    From weex with Apache License 2.0 5 votes vote down vote up
public void setRadius(float radius, int position) {
  if (mBorderCornerRadii == null) {
    mBorderCornerRadii = new float[4];
    Arrays.fill(mBorderCornerRadii, CSSConstants.UNDEFINED);
  }

  if (!FloatUtil.floatsEqual(mBorderCornerRadii[position], radius)) {
    mBorderCornerRadii[position] = radius;
    mNeedUpdatePathForBorderRadius = true;
    invalidateSelf();
  }
}
 
Example #5
Source File: BorderDrawable.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setBorderWidth(@BorderWidthStyleColorType int position, float width) {
  if (mBorderWidth == null) {
    mBorderWidth = new SparseArray<>(5);
    mBorderWidth.put(Spacing.ALL, DEFAULT_BORDER_WIDTH);
  }
  if (!FloatUtil.floatsEqual(getBorderWidth(position), width)) {
    BorderUtil.updateSparseArray(mBorderWidth, position, width);
    mBorderWidth.put(position, width);
    mNeedUpdatePath = true;
    invalidateSelf();
  }
}
 
Example #6
Source File: BorderDrawable.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void setBorderRadius(@BorderRadiusType int position, float radius) {
  if (mBorderRadius == null) {
    mBorderRadius = new SparseArray<>(5);
    mBorderRadius.put(Spacing.ALL, DEFAULT_BORDER_RADIUS);
  }
  if (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, position), radius)) {
    BorderUtil.updateSparseArray(mBorderRadius, position, radius, true);
    mNeedUpdatePath = true;
    invalidateSelf();
  }
}
 
Example #7
Source File: BorderDrawable.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public boolean isRounded() {
  return mBorderRadius != null &&
         (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0));
}
 
Example #8
Source File: BorderDrawable.java    From weex-uikit with MIT License 5 votes vote down vote up
public void setBorderWidth(int position, float width) {
  if (mBorderWidth == null) {
    mBorderWidth = new SparseArray<>(5);
    mBorderWidth.put(Spacing.ALL, DEFAULT_BORDER_WIDTH);
  }
  if (!FloatUtil.floatsEqual(getBorderWidth(position), width)) {
    BorderUtil.updateSparseArray(mBorderWidth, position, width);
    mBorderWidth.put(position, width);
    mNeedUpdatePath = true;
    invalidateSelf();
  }
}
 
Example #9
Source File: BorderDrawable.java    From weex-uikit with MIT License 5 votes vote down vote up
public void setBorderRadius(int position, float radius) {
  if (mBorderRadius == null) {
    mBorderRadius = new SparseArray<>(5);
    mBorderRadius.put(Spacing.ALL, DEFAULT_BORDER_RADIUS);
  }
  if (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, position), radius)) {
    BorderUtil.updateSparseArray(mBorderRadius, position, radius, true);
    mNeedUpdatePath = true;
    invalidateSelf();
  }
}
 
Example #10
Source File: BorderDrawable.java    From weex-uikit with MIT License 5 votes vote down vote up
public boolean isRounded() {
  return mBorderRadius != null &&
         (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) ||
          !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0));
}
 
Example #11
Source File: WXBackgroundDrawable.java    From weex with Apache License 2.0 5 votes vote down vote up
public void setRadius(float radius) {
  if (!FloatUtil.floatsEqual(mBorderRadius, radius)) {
    mBorderRadius = radius;
    mNeedUpdatePathForBorderRadius = true;
    invalidateSelf();
  }
}
 
Example #12
Source File: BorderDrawable.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
private void updateFactor(@NonNull List<Float> list, float numerator, float denominator) {
  if (!FloatUtil.floatsEqual(denominator, 0)) {
    list.add(numerator / denominator);
  }
}
 
Example #13
Source File: BorderDrawable.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
private void drawOneSide(Canvas canvas, @NonNull BorderEdge borderEdge) {
  if (!FloatUtil.floatsEqual(0, getBorderWidth(borderEdge.getEdge()))) {
    preparePaint(borderEdge.getEdge());
    borderEdge.drawEdge(canvas, mPaint);
  }
}
 
Example #14
Source File: BorderDrawable.java    From weex-uikit with MIT License 4 votes vote down vote up
private void updateFactor(@NonNull List<Float> list, float numerator, float denominator) {
  if (!FloatUtil.floatsEqual(denominator, 0)) {
    list.add(numerator / denominator);
  }
}
 
Example #15
Source File: BorderDrawable.java    From weex-uikit with MIT License 4 votes vote down vote up
private void drawOneSide(Canvas canvas, @NonNull BorderEdge borderEdge) {
  if (!FloatUtil.floatsEqual(0, getBorderWidth(borderEdge.getEdge()))) {
    preparePaint(borderEdge.getEdge());
    borderEdge.drawEdge(canvas, mPaint);
  }
}
 
Example #16
Source File: BorderCorner.java    From weex-uikit with MIT License 2 votes vote down vote up
/**
 * Tell whether this corner has a rounded outer corner.
 * @return true for a rounded outer corner, otherwise false.
 */
boolean hasOuterCorner() {
  return getOuterCornerRadius() > 0 && !FloatUtil.floatsEqual(0, getOuterCornerRadius());
}
 
Example #17
Source File: BorderCorner.java    From ucar-weex-core with Apache License 2.0 2 votes vote down vote up
/**
 * Tell whether this corner has a rounded outer corner.
 * @return true for a rounded outer corner, otherwise false.
 */
boolean hasOuterCorner() {
  return getOuterCornerRadius() > 0 && !FloatUtil.floatsEqual(0, getOuterCornerRadius());
}