Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
katherine95s committed Aug 29, 2019
1 parent f24755d commit eca9162
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
if (!TextUtils.isEmpty(style.width)) {
holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width,
(int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)));
(int) WXViewUtils.getRealPxByWidth(style.width,0.0f, viewPortWidth)));
}
if (!TextUtils.isEmpty(style.height)) {
holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height,
(int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)));
(int) WXViewUtils.getRealPxByWidth(style.width,0.0f, viewPortWidth)));
}
}

Expand Down
16 changes: 13 additions & 3 deletions android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public static boolean isUndefined(float value) {
return Float.isNaN(value);
}


/**
* Use {@link WXViewUtils#getRealPxByWidth(Object, float, int)} instead.
*/
@Deprecated
public static float getFloatByViewport(Object value, int viewport) {
if (value == null) {
return Float.NaN;
Expand Down Expand Up @@ -89,11 +92,18 @@ public static float getFloatByViewport(Object value, int viewport) {
}
return Float.NaN;
}

/**
* Use {@link WXViewUtils#getRealPxByWidth(Object, float, int)} instead.
*/
@Deprecated
public static float getFloat(Object value) {
return getFloat(value, Float.NaN);
}

/**
* Use {@link WXViewUtils#getRealPxByWidth(Object, float, int)} instead.
*/
@Deprecated
public static Float getFloat(Object value, @Nullable Float df) {
if (value == null) {
return df;
Expand Down Expand Up @@ -135,7 +145,7 @@ public static Float getFloat(Object value, @Nullable Float df) {
return df;
}

public static float transferWx(String stringWithWXPostfix, int viewport) {
static float transferWx(String stringWithWXPostfix, int viewport) {
if(null == stringWithWXPostfix) {
return 0;
}
Expand Down
13 changes: 11 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,19 @@ public static int getScreenHeight(Context cxt) {
* @return the actual distance in the screen.
*/


/**
* Use {@link WXViewUtils#getRealPxByWidth(Object, float, int)} instead.
*/
@Deprecated
public static float getRealPxByWidth(float pxValue) {
return getRealPxByWidth(pxValue,750);
}

/**
* Use {@link WXViewUtils#getRealPxByWidth(Object, float, int)} instead.
*/
@Deprecated
public static float getRealPxByWidth(float pxValue,int customViewport) {
if (Float.isNaN(pxValue)) {
return pxValue;
Expand Down Expand Up @@ -303,9 +312,9 @@ public static float getRealPxByWidth(Object value, float df, int customViewport)
pxValue = Float.parseFloat(temp);
}
} catch (NumberFormatException nfe) {
WXLogUtils.e("Argument format error! value is " + temp, nfe);
WXLogUtils.e("Argument format error! value is " + temp, WXLogUtils.getStackTrace(nfe));
} catch (Exception e) {
WXLogUtils.e("Argument error! value is " + temp, e);
WXLogUtils.e("Argument error! value is " + temp, WXLogUtils.getStackTrace(e));
}
if (mUseWebPx) {
return (float) Math.rint(pxValue);
Expand Down

0 comments on commit eca9162

Please sign in to comment.