From 9fc2cc61a4a7c650a1838e3472482d298d53013d Mon Sep 17 00:00:00 2001 From: zshshr Date: Thu, 2 Aug 2018 15:47:06 +0800 Subject: [PATCH] * [android] add pagingEnabled ="true" attribute of list component --- .../main/java/com/taobao/weex/common/Constants.java | 3 +++ .../taobao/weex/ui/component/list/WXListComponent.java | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java index 1dc90190e6..d077dcdffa 100644 --- a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java +++ b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java @@ -217,6 +217,9 @@ public interface Name { String INCLUDE_FONT_PADDING = "includeFontPadding"; String ENABLE_COPY = "enableCopy"; + String PAGE_ENABLED = "pagingEnabled"; + + interface Recycler{ String LIST_DATA = "listData"; diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java index 0439345cdd..195d2ae0db 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXListComponent.java @@ -26,6 +26,7 @@ import com.alibaba.fastjson.JSON; import android.content.Context; +import android.support.v7.widget.PagerSnapHelper; import android.text.TextUtils; import com.taobao.weex.WXSDKInstance; import com.taobao.weex.annotation.Component; @@ -81,6 +82,15 @@ protected BounceRecyclerView generateListView(Context context, int orientation) bounceRecyclerView.getSwipeLayout().setNestedScrollingEnabled(true); } } + + /** + * enable pagingEnabled attr + */ + if(WXUtils.getBoolean(getAttrs().get(Constants.Name.PAGE_ENABLED),false)){ + PagerSnapHelper snapHelper = new PagerSnapHelper(); + snapHelper.attachToRecyclerView(bounceRecyclerView.getInnerView()); + } + return bounceRecyclerView; }