You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2017/08/30 12:56:36 UTC

[1/2] incubator-weex git commit: * [android] handle undefined&auto value to Float.NaN

Repository: incubator-weex
Updated Branches:
  refs/heads/0.16-dev 4d176e068 -> 58441fa47


* [android] handle undefined&auto value to Float.NaN


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/6016c338
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/6016c338
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/6016c338

Branch: refs/heads/0.16-dev
Commit: 6016c3388d737173099f4e4285f127533128ae6e
Parents: 4d176e0
Author: zshshr <zh...@gmail.com>
Authored: Wed Aug 30 16:24:16 2017 +0800
Committer: zshshr <zh...@gmail.com>
Committed: Wed Aug 30 16:24:16 2017 +0800

----------------------------------------------------------------------
 .../java/com/taobao/weex/common/Constants.java  |  1 +
 .../java/com/taobao/weex/utils/WXUtils.java     | 64 +++++++++++---------
 2 files changed, 37 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6016c338/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
index 92cb971..06fb668 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
@@ -180,6 +180,7 @@ public class Constants {
     String NORMAL = "normal";
     String ARIA_LABEL = "ariaLabel";
     String ARIA_HIDDEN = "ariaHidden";
+    String UNDEFINED = "undefined";
   }
 
   public interface Value {

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/6016c338/android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java
index 52cf7e0..a11e54a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXUtils.java
@@ -25,6 +25,7 @@ import android.os.Looper;
 import android.support.annotation.Nullable;
 import android.text.TextUtils;
 import com.taobao.weex.WXEnvironment;
+import com.taobao.weex.common.Constants;
 import com.taobao.weex.common.WXConfig;
 
 public class WXUtils {
@@ -48,34 +49,38 @@ public class WXUtils {
     if (value == null) {
       return Float.NaN;
     }
-
     String temp = value.toString().trim();
-    if(!TextUtils.isEmpty(temp)) {
-      if (temp.endsWith("wx")) {
-        try {
-          return transferWx(temp, viewport);
-        } catch (NumberFormatException e) {
-          WXLogUtils.e("Argument format error! value is " + value, e);
-        } catch (Exception e) {
-          WXLogUtils.e("Argument error! value is " + value, e);
-        }
-      } else if (temp.endsWith("px")) {
-        try {
-          temp = temp.substring(0, temp.indexOf("px"));
-          return Float.parseFloat(temp);
-        } catch (NumberFormatException nfe) {
-          WXLogUtils.e("Argument format error! value is " + value, nfe);
-        } catch (Exception e) {
-          WXLogUtils.e("Argument error! value is " + value, e);
-        }
-      } else {
-        try {
-          return Float.parseFloat(temp);
-        } catch (NumberFormatException nfe) {
-          WXLogUtils.e("Argument format error! value is " + value, nfe);
-        } catch (Exception e) {
-          WXLogUtils.e("Argument error! value is " + value, e);
-        }
+    if (Constants.Name.AUTO.equals(temp)
+        || Constants.Name.UNDEFINED.equals(temp)
+        || TextUtils.isEmpty(temp)) {
+      WXLogUtils.e("Argument Warning ! value is " + temp + "And default Value:" + Float.NaN);
+      return Float.NaN;
+    }
+
+    if (temp.endsWith("wx")) {
+      try {
+        return transferWx(temp, viewport);
+      } catch (NumberFormatException e) {
+        WXLogUtils.e("Argument format error! value is " + value, e);
+      } catch (Exception e) {
+        WXLogUtils.e("Argument error! value is " + value, e);
+      }
+    } else if (temp.endsWith("px")) {
+      try {
+        temp = temp.substring(0, temp.indexOf("px"));
+        return Float.parseFloat(temp);
+      } catch (NumberFormatException nfe) {
+        WXLogUtils.e("Argument format error! value is " + value, nfe);
+      } catch (Exception e) {
+        WXLogUtils.e("Argument error! value is " + value, e);
+      }
+    } else {
+      try {
+        return Float.parseFloat(temp);
+      } catch (NumberFormatException nfe) {
+        WXLogUtils.e("Argument format error! value is " + value, nfe);
+      } catch (Exception e) {
+        WXLogUtils.e("Argument error! value is " + value, e);
       }
     }
     return Float.NaN;
@@ -91,7 +96,10 @@ public class WXUtils {
     }
 
     String temp = value.toString().trim();
-    if(TextUtils.isEmpty(temp)){
+    if(Constants.Name.AUTO.equals(temp)
+        || Constants.Name.UNDEFINED.equals(temp)
+        || TextUtils.isEmpty(temp)){
+      WXLogUtils.e("Argument Warning ! value is " + temp + "And default Value:"+Float.NaN);
       return df;
     }
     if (temp.endsWith("wx")) {


[2/2] incubator-weex git commit: * [android] fix list memory leak when exist more than one

Posted by ky...@apache.org.
* [android] fix list memory leak when exist more than one


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/58441fa4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/58441fa4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/58441fa4

Branch: refs/heads/0.16-dev
Commit: 58441fa4794ae1aa9693e865457ed25750eefd2b
Parents: 6016c33
Author: zshshr <zh...@gmail.com>
Authored: Wed Aug 30 18:04:58 2017 +0800
Committer: zshshr <zh...@gmail.com>
Committed: Wed Aug 30 18:04:58 2017 +0800

----------------------------------------------------------------------
 .../ui/component/list/BasicListComponent.java   | 42 ++++----------------
 1 file changed, 7 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/58441fa4/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
index 66eb75b..f6fe78d 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
@@ -92,8 +92,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
   private String TAG = "BasicListComponent";
   private int mListCellCount = 0;
   private boolean mForceLoadmoreNextTime = false;
-  private ArrayList<ListBaseViewHolder> recycleViewList = new ArrayList<>();
-  private static int visibleCellCount = 6;
   private static final Pattern transformPattern = Pattern.compile("([a-z]+)\\(([0-9\\.]+),?([0-9\\.]+)?\\)");
 
   private Map<String, AppearanceHelper> mAppearComponents = new HashMap<>();
@@ -302,9 +300,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
         super.onScrollStateChanged(recyclerView, newState);
 
-        if (newState == RecyclerView.SCROLL_STATE_IDLE)
-          recycleViewHolderList();
-
         List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
         if (listeners != null && listeners.size() > 0) {
           for (OnWXScrollListener listener : listeners) {
@@ -360,17 +355,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
     return bounceRecyclerView;
   }
 
-  private void recycleViewHolderList() {
-    for (ListBaseViewHolder holder : recycleViewList) {
-      if (holder != null
-              && holder.getComponent() != null
-              && !holder.getComponent().isUsing()) {
-        holder.recycled();
-      }
-    }
-    recycleViewList.clear();
-  }
-
   @Override
   public void bindStickStyle(WXComponent component) {
     stickyHelper.bindStickStyle(component, mStickyMap);
@@ -806,23 +790,14 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
     long begin = System.currentTimeMillis();
 
     holder.setComponentUsing(false);
-    if(holder.canRecycled()) {
-      recycleViewList.add(holder);
-
-      // recycleViewList allowed max size
-      int threshold = visibleCellCount >= 6 ? (visibleCellCount * 6) : (6*6);
-
-      /**
-       * Recycle cache{@link recycleViewList} when recycleViewList.size() > list max child count or threshold
-       */
-      if (recycleViewList.size() > getChildCount() + 1 || recycleViewList.size() >= threshold) {
-        WXLogUtils.d(TAG, "Recycle holder list recycled : cache size is " + recycleViewList.size() +
-                ", visibleCellCount is " + visibleCellCount + ", threshold is " + threshold +
-                ", child count is " + getChildCount());
-        recycleViewHolderList();
-      }
+    if (holder != null
+        && holder.canRecycled()
+        && holder.getComponent() != null
+        && !holder.getComponent().isUsing()) {
+      holder.recycled();
+
     } else {
-      WXLogUtils.w(TAG, "this holder can not be allowed to  recycled" );
+      WXLogUtils.w(TAG, "this holder can not be allowed to  recycled");
     }
     if (WXEnvironment.isApkDebugable()) {
       WXLogUtils.d(TAG, "Recycle holder " + (System.currentTimeMillis() - begin) + "  Thread:" + Thread.currentThread().getName());
@@ -1195,9 +1170,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
     }
 
-    if (mColumnCount > 0)
-      visibleCellCount = (lastVisible - firstVisible) * mColumnCount;
-
     while (it.hasNext()) {
       AppearanceHelper item = it.next();
       WXComponent component = item.getAwareChild();