weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] YorkShen closed pull request #1945: [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd But Touch Not End
Date Fri, 21 Dec 2018 08:45:52 GMT
YorkShen closed pull request #1945: [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd
But Touch Not End
URL: https://github.com/apache/incubator-weex/pull/1945
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
index 2f6554d7ea..e4ab9f8b6a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
@@ -575,6 +575,7 @@ public void onScrollStopped(WXScrollView scrollView, int x, int y) {
               }
             }
           }
+          getScrollStartEndHelper().onScrollStateChanged(OnWXScrollListener.IDLE);
         }
 
         @Override
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/helper/ScrollStartEndHelper.java
b/android/sdk/src/main/java/com/taobao/weex/ui/component/helper/ScrollStartEndHelper.java
index 871f86aedd..85c43f965c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/helper/ScrollStartEndHelper.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/helper/ScrollStartEndHelper.java
@@ -22,6 +22,7 @@
 import android.os.Looper;
 
 import com.taobao.weex.common.Constants;
+import com.taobao.weex.common.OnWXScrollListener;
 import com.taobao.weex.ui.component.WXComponent;
 import com.taobao.weex.ui.component.WXScroller;
 import com.taobao.weex.ui.component.list.BasicListComponent;
@@ -45,6 +46,8 @@
 
     private int x;
     private int y;
+    private boolean hasScrollEnd;
+
 
     public ScrollStartEndHelper(WXComponent component) {
         this.component = component;
@@ -78,10 +81,15 @@ public void run() {
         if(component.isDestoryed()){
             return;
         }
+        if(!hasScrollEnd){
+            return;
+        }
         if(component.getEvents().contains(Constants.Event.SCROLL_END)){
             component.fireEvent(Constants.Event.SCROLL_END, getScrollEvent(this.x, this.y));
         }
         hasStart = false;
+        hasScrollEnd = false;
+
     }
 
     private Map<String, Object> getScrollEvent(int offsetX, int offsetY){
@@ -103,6 +111,14 @@ public void run() {
         return null;
     }
 
+    public void onScrollStateChanged(int newState){
+        if(newState == OnWXScrollListener.IDLE){
+            hasScrollEnd = true;
+            handler.removeCallbacks(this);
+            handler.postDelayed(this, minInterval);
+        }
+    }
+
 
     public static boolean isScrollEvent(String type){
         if(Constants.Event.SCROLL.equals(type)){
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 b3546d1a69..60655e56c3 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
@@ -319,7 +319,7 @@ protected T initComponentHostView(@NonNull Context context) {
       @Override
       public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
         super.onScrollStateChanged(recyclerView, newState);
-
+        getScrollStartEndHelper().onScrollStateChanged(newState);
         List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
         int size;
         OnWXScrollListener listener;
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
index 6b7e233969..5831cb9116 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
@@ -290,6 +290,7 @@ protected BounceRecyclerView initComponentHostView(@NonNull Context context)
{
             @Override
             public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                 super.onScrollStateChanged(recyclerView, newState);
+                getScrollStartEndHelper().onScrollStateChanged(newState);
                 List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
                 if (listeners != null && listeners.size() > 0) {
                     for (OnWXScrollListener listener : listeners) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message