nest scroll check

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

Branch: refs/heads/master
Commit: 69f634a420df660433536d7630376222ace8e647
Parents: 1f54c7d
Author: jianbai.gbj <jianbai....@alibaba-inc.com>
Authored: Thu Oct 26 20:06:36 2017 +0800
Committer: jianbai.gbj <jianbai....@alibaba-inc.com>
Committed: Thu Oct 26 20:06:36 2017 +0800

----------------------------------------------------------------------
 .../com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/69f634a4/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java
----------------------------------------------------------------------
diff --git 
a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java
 
b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java
index b8c8465..1676c99 100644
--- 
a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java
+++ 
b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/core/WXSwipeLayout.java
@@ -44,6 +44,7 @@ public class WXSwipeLayout extends FrameLayout implements 
NestedScrollingParent,
   private NestedScrollingChildHelper mNestedScrollingChildHelper;
   private final int[] mParentScrollConsumed = new int[2];
   private final int[] mParentOffsetInWindow = new int[2];
+  private boolean mNestedScrollInProgress;
   private WXOnRefreshListener onRefreshListener;
   private WXOnLoadingListener onLoadingListener;
 
@@ -210,6 +211,12 @@ public class WXSwipeLayout extends FrameLayout implements 
NestedScrollingParent,
     if ((!mPullRefreshEnable && !mPullLoadEnable)) {
       return false;
     }
+    if (!isEnabled() || canChildScrollUp()
+            || mRefreshing || mNestedScrollInProgress) {
+      // Fail fast if we're not in a state where a swipe is possible
+      return false;
+    }
+
     return super.onInterceptTouchEvent(ev);
   }
 
@@ -287,6 +294,7 @@ public class WXSwipeLayout extends FrameLayout implements 
NestedScrollingParent,
   public void onNestedScrollAccepted(View child, View target, int axes) {
     mNestedScrollingParentHelper.onNestedScrollAccepted(child, target, axes);
     startNestedScroll(axes & ViewCompat.SCROLL_AXIS_VERTICAL);
+    mNestedScrollInProgress = true;
   }
 
   /**
@@ -297,6 +305,7 @@ public class WXSwipeLayout extends FrameLayout implements 
NestedScrollingParent,
   @Override
   public void onStopNestedScroll(View child) {
     mNestedScrollingParentHelper.onStopNestedScroll(child);
+    mNestedScrollInProgress = true;
     handlerAction();
     stopNestedScroll();
   }

Reply via email to