You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/09/21 13:39:13 UTC

[46/50] [abbrv] incubator-weex git commit: use apache

use apache


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

Branch: refs/heads/0.16-dev
Commit: 4a3b537cd6c83ed76d6a80b636a0d65936d38741
Parents: c7b9938
Author: jianbai.gbj <ji...@alibaba-inc.com>
Authored: Thu Sep 21 17:48:32 2017 +0800
Committer: jianbai.gbj <ji...@alibaba-inc.com>
Committed: Thu Sep 21 17:48:32 2017 +0800

----------------------------------------------------------------------
 .../ui/component/list/BasicListComponent.java   | 122 +++++++++----------
 1 file changed, 61 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4a3b537c/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 5393f9a..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
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- *
+ * 
  *   http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -86,7 +86,7 @@ import java.util.regex.Pattern;
  */
 
 public abstract class BasicListComponent<T extends ViewGroup & ListComponentView> extends WXVContainer<T> implements
-        IRecyclerAdapterListener<ListBaseViewHolder>, IOnLoadMoreListener, Scrollable {
+    IRecyclerAdapterListener<ListBaseViewHolder>, IOnLoadMoreListener, Scrollable {
   public static final String TRANSFORM = "transform";
   public static final String LOADMOREOFFSET = "loadmoreoffset";
   private String TAG = "BasicListComponent";
@@ -561,62 +561,62 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       stickyComponent = entry.getValue();
 
       if (stickyComponent != null && stickyComponent.getDomObject() != null
-              && stickyComponent instanceof WXCell) {
+          && stickyComponent instanceof WXCell) {
 
         WXCell cell = (WXCell) stickyComponent;
         if (cell.getHostView() == null) {
           return;
         }
 
-        RecyclerView.LayoutManager layoutManager;
-        boolean beforeFirstVisibleItem = false;
-        boolean removeOldSticky = false;
-        layoutManager = getHostView().getInnerView().getLayoutManager();
-        if (layoutManager instanceof LinearLayoutManager || layoutManager instanceof GridLayoutManager) {
-          int fVisible = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
-          int pos = mChildren.indexOf(cell);
-          cell.setScrollPositon(pos);
-
-          if (pos <= fVisible) {
-            beforeFirstVisibleItem = true;
-            if(pos > currentStickyPos) {
-              currentStickyPos = pos;
+          RecyclerView.LayoutManager layoutManager;
+          boolean beforeFirstVisibleItem = false;
+          boolean removeOldSticky = false;
+          layoutManager = getHostView().getInnerView().getLayoutManager();
+          if (layoutManager instanceof LinearLayoutManager || layoutManager instanceof GridLayoutManager) {
+            int fVisible = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
+            int pos = mChildren.indexOf(cell);
+            cell.setScrollPositon(pos);
+
+            if (pos <= fVisible) {
+              beforeFirstVisibleItem = true;
+              if(pos > currentStickyPos) {
+                currentStickyPos = pos;
+              }
             }
-          }
 
-          if(pos > fVisible){
-            removeOldSticky = true;
-          }
-        } else if(layoutManager instanceof StaggeredGridLayoutManager){
-          int [] firstItems= new int[3];
-          int fVisible = ((StaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(firstItems)[0];
-          int pos = mChildren.indexOf(cell);
+            if(pos > fVisible){
+              removeOldSticky = true;
+            }
+          } else if(layoutManager instanceof StaggeredGridLayoutManager){
+            int [] firstItems= new int[3];
+            int fVisible = ((StaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(firstItems)[0];
+            int pos = mChildren.indexOf(cell);
 
-          if (pos <= fVisible) {
-            beforeFirstVisibleItem = true;
-          }
+            if (pos <= fVisible) {
+              beforeFirstVisibleItem = true;
+            }
 
-          if(pos > fVisible){
-            removeOldSticky = true;
+            if(pos > fVisible){
+              removeOldSticky = true;
+            }
           }
-        }
 
-        int[] location = new int[2];
-        stickyComponent.getHostView().getLocationOnScreen(location);
-        int[] parentLocation = new int[2];
-        stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
+          int[] location = new int[2];
+          stickyComponent.getHostView().getLocationOnScreen(location);
+          int[] parentLocation = new int[2];
+          stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
 
-        int top = location[1] - parentLocation[1];
+          int top = location[1] - parentLocation[1];
 
-        boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= 0 && dy >= 0;
-        boolean removeSticky = cell.getLocationFromStart() <= 0 && top > 0 && dy <= 0;
-        if (showSticky) {
-          bounceRecyclerView.notifyStickyShow(cell);
-        } else if (removeSticky || removeOldSticky) {
-          bounceRecyclerView.notifyStickyRemove(cell);
+          boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= 0 && dy >= 0;
+          boolean removeSticky = cell.getLocationFromStart() <= 0 && top > 0 && dy <= 0;
+          if (showSticky) {
+            bounceRecyclerView.notifyStickyShow(cell);
+          } else if (removeSticky || removeOldSticky) {
+            bounceRecyclerView.notifyStickyRemove(cell);
+          }
+          cell.setLocationFromStart(top);
         }
-        cell.setLocationFromStart(top);
-      }
     }
 
     if(currentStickyPos>=0){
@@ -690,7 +690,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       if (child.getDomObject() != null) {
         Object attr = child.getDomObject().getAttrs().get(Constants.Name.KEEP_SCROLL_POSITION);
         if (WXUtils.getBoolean(attr, false) && index <= getChildCount() && index>-1) {
-          isKeepScrollPosition = true;
+            isKeepScrollPosition = true;
         }
       }
       if (isKeepScrollPosition) {
@@ -791,9 +791,9 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
 
     holder.setComponentUsing(false);
     if (holder != null
-            && holder.canRecycled()
-            && holder.getComponent() != null
-            && !holder.getComponent().isUsing()) {
+        && holder.canRecycled()
+        && holder.getComponent() != null
+        && !holder.getComponent().isUsing()) {
       holder.recycled();
 
     } else {
@@ -816,10 +816,10 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
     holder.setComponentUsing(true);
     WXComponent component = getChild(position);
     if (component == null
-            || (component instanceof WXRefresh)
-            || (component instanceof WXLoading)
-            || (component.getDomObject() != null && component.getDomObject().isFixed())
-            ) {
+        || (component instanceof WXRefresh)
+        || (component instanceof WXLoading)
+        || (component.getDomObject() != null && component.getDomObject().isFixed())
+        ) {
       if (WXEnvironment.isApkDebugable()) {
         WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
       }
@@ -827,11 +827,11 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
               && holder.getView() != null
               && component.getDomObject() != null
               && (component.getDomObject().getAttrs().get("holderBackground") != null)){
-        Object holderBackground = component.getDomObject().getAttrs().get("holderBackground");
+         Object holderBackground = component.getDomObject().getAttrs().get("holderBackground");
         int color = WXResourceUtils.getColor(holderBackground.toString(), Color.WHITE);
-        holder.getView().setBackgroundColor(color);
-        holder.getView().setVisibility(View.VISIBLE);
-        holder.getView().postInvalidate();
+         holder.getView().setBackgroundColor(color);
+         holder.getView().setVisibility(View.VISIBLE);
+         holder.getView().postInvalidate();
       }
       return;
     }
@@ -849,8 +849,8 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       WXCell cell = (WXCell) holder.getComponent();
       boolean isExcluded = DEFAULT_EXCLUDED;
       if(cell.getDomObject() != null){
-        WXAttr cellAttrs = cell.getDomObject().getAttrs();
-        isExcluded = WXUtils.getBoolean(cellAttrs.get(EXCLUDED), DEFAULT_EXCLUDED);
+         WXAttr cellAttrs = cell.getDomObject().getAttrs();
+         isExcluded = WXUtils.getBoolean(cellAttrs.get(EXCLUDED), DEFAULT_EXCLUDED);
       }
 
       mDragHelper.setDragExcluded(holder, isExcluded);
@@ -916,7 +916,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       for (int i = 0; i < mTypes.size(); i++) {
         WXComponent component = mTypes.get(i);
         if (component == null
-                || component.isUsing()) {
+            || component.isUsing()) {
           continue;
         }
         if (component.getDomObject() != null && component.getDomObject().isFixed()) {
@@ -1149,7 +1149,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
       if (offScreenY <= offsetParsed) {
 
         if (mListCellCount != mChildren.size()
-                || mForceLoadmoreNextTime) {
+            || mForceLoadmoreNextTime) {
           fireEvent(Constants.Event.LOADMORE);
           mListCellCount = mChildren.size();
           mForceLoadmoreNextTime = false;
@@ -1165,7 +1165,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
     //notify appear state
     Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
     String direction = directionY > 0 ? Constants.Value.DIRECTION_UP :
-            directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
+        directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
     if (getOrientation() == Constants.Orientation.HORIZONTAL && directionX != 0) {
       direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
     }