Repository: incubator-weex
Updated Branches:
  refs/heads/release-0.16 e391f39ff -> e2323d214


when touch  use scroll handler, when none touch use nonstop


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

Branch: refs/heads/release-0.16
Commit: 661e0a03c921925c5e66fdcd23fbb70a209c7850
Parents: febb720
Author: jianbai.gbj <jianbai....@alibaba-inc.com>
Authored: Thu Oct 19 17:57:54 2017 +0800
Committer: jianbai.gbj <jianbai....@alibaba-inc.com>
Committed: Thu Oct 19 17:57:54 2017 +0800

----------------------------------------------------------------------
 .../weex/ui/view/listview/WXRecyclerView.java   | 24 +++++++++++++-------
 1 file changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/661e0a03/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
----------------------------------------------------------------------
diff --git 
a/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
 
b/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
index 20be140..b2a1793 100644
--- 
a/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
+++ 
b/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
@@ -42,6 +42,8 @@ public class WXRecyclerView extends RecyclerView implements 
WXGestureObservable
   public static final int TYPE_STAGGERED_GRID_LAYOUT = 3;
   private WXGesture mGesture;
   private boolean scrollable = true;
+  private boolean hasTouch = false;
+
 
   public WXRecyclerView(Context context) {
     super(context);
@@ -91,6 +93,7 @@ public class WXRecyclerView extends RecyclerView implements 
WXGestureObservable
     if(!scrollable) {
       return true;
     }
+    hasTouch = true;
     boolean result = super.onTouchEvent(event);
     if (mGesture != null) {
       result |= mGesture.onTouch(this, event);
@@ -110,26 +113,31 @@ public class WXRecyclerView extends RecyclerView 
implements WXGestureObservable
       }
       //Any else?
     } else {
+      smoothScrollToPosition(position);
       if (offset != 0) {
         setOnSmoothScrollEndListener(new 
ExtendedLinearLayoutManager.OnSmoothScrollEndListener() {
           @Override
           public void onStop() {
-            if (orientation == Constants.Orientation.VERTICAL) {
-                smoothScrollBy(0, offset);
-            } else {
-                smoothScrollBy(offset, 0);
-            }
+            post(new Runnable() {
+              @Override
+              public void run() {
+                if (orientation == Constants.Orientation.VERTICAL) {
+                  smoothScrollBy(0, offset);
+                } else {
+                  smoothScrollBy(offset, 0);
+                }
+              }
+            });
           }
         });
       }
-      smoothScrollToPosition(position);
     }
   }
 
   public void setOnSmoothScrollEndListener(final 
ExtendedLinearLayoutManager.OnSmoothScrollEndListener 
onSmoothScrollEndListener){
-    if(getLayoutManager() instanceof ExtendedLinearLayoutManager){
+    if(getLayoutManager() instanceof ExtendedLinearLayoutManager && !hasTouch){
        ExtendedLinearLayoutManager extendedLinearLayoutManager = 
(ExtendedLinearLayoutManager)getLayoutManager();
-       
extendedLinearLayoutManager.setOnScrollEndListener(onSmoothScrollEndListener);
+      
extendedLinearLayoutManager.setOnScrollEndListener(onSmoothScrollEndListener);
     }else{
       addOnScrollListener(new RecyclerView.OnScrollListener() {
         @Override

Reply via email to