weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ky...@apache.org
Subject [incubator-weex] branch master updated: [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd But Touch Not End (#1945)
Date Fri, 21 Dec 2018 08:45:55 GMT
This is an automated email from the ASF dual-hosted git repository.

kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new 0bb4d4c  [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd But Touch Not End
(#1945)
0bb4d4c is described below

commit 0bb4d4c40078067318db1f39d2a614f35e5a3536
Author: codefurture <gubaojian@163.com>
AuthorDate: Fri Dec 21 16:45:51 2018 +0800

    [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd But Touch Not End (#1945)
    
    * [WEEX][Android] Fix Scroll End Be Fired When ScrollEnd But Touch Not End
---
 .../java/com/taobao/weex/ui/component/WXScroller.java    |  1 +
 .../weex/ui/component/helper/ScrollStartEndHelper.java   | 16 ++++++++++++++++
 .../weex/ui/component/list/BasicListComponent.java       |  2 +-
 .../component/list/template/WXRecyclerTemplateList.java  |  1 +
 4 files changed, 19 insertions(+), 1 deletion(-)

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 2f6554d..e4ab9f8 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 class WXScroller extends WXVContainer<ViewGroup> implements
WXScrollViewL
               }
             }
           }
+          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 871f86a..85c43f9 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.Handler;
 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 @@ public class ScrollStartEndHelper implements Runnable{
 
     private int x;
     private int y;
+    private boolean hasScrollEnd;
+
 
     public ScrollStartEndHelper(WXComponent component) {
         this.component = component;
@@ -78,10 +81,15 @@ public class ScrollStartEndHelper implements Runnable{
         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 class ScrollStartEndHelper implements Runnable{
         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 3d7393f..7b86229 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 @@ public abstract class BasicListComponent<T extends ViewGroup &
ListComponentView
       @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 6b7e233..5831cb9 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 @@ public class WXRecyclerTemplateList extends WXVContainer<BounceRecyclerView>
imp
             @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) {


Mime
View raw message