YorkShen commented on a change in pull request #2783: [Android]support "wx" in
animation and wxtext
URL: https://github.com/apache/incubator-weex/pull/2783#discussion_r318938741
##########
File path: android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
##########
@@ -280,6 +281,42 @@ public static float getRealPxByWidth(float pxValue,int
customViewport) {
return realPx > 0.005 && realPx < 1 ? 1 : (float) Math.rint(realPx);
}
}
+ public static float getRealPxByWidth(Object value, float df, int
customViewport) {
+ Float pxValue = df;
+ if (value == null) {
+ return df;
+ }
+ String temp = value.toString().trim();
+ if (Constants.Name.AUTO.equals(temp)
+ || Constants.Name.UNDEFINED.equals(temp)
+ || TextUtils.isEmpty(temp)) {
+ WXLogUtils.e("Argument Warning ! value is " + temp + "And default
Value:" + df);
+ return df;
+ }
+ try {
+ if (temp.endsWith("wx")) {
+ pxValue = WXUtils.transferWx(temp, customViewport);
+ } else if (temp.endsWith("px")) {
+ temp = temp.substring(0, temp.indexOf("px"));
+ pxValue = Float.parseFloat(temp);
+ } else {
+ pxValue = Float.parseFloat(temp);
+ }
+ } catch (NumberFormatException nfe) {
+ WXLogUtils.e("Argument format error! value is " + temp, nfe);
Review comment:
Use `WXLogUtils.getStackTrace(e)` to print stacktrace.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services